1 <?xml version="1.0" encoding="UTF-8"?>
\r
2 <!DOCTYPE sect1 SYSTEM "../../../dtd/dblite.dtd">
\r
3 <sect1 id="tsvn-dug-rename">
\r
4 <title>Deleting, Moving and Renaming</title>
\r
6 Unlike CVS, Git allows renaming and moving of files and
\r
7 folders. So there are menu entries for delete and rename
\r
8 in the TortoiseGit submenu.
\r
9 <figure id="tsvn-dug-renaming-dia-1">
\r
10 <title>Explorer context menu for versioned files</title>
\r
11 <graphic fileref="../images/ContextMenuFileControl.png"/>
\r
14 <sect2 id="tsvn-dug-rename-delete">
\r
15 <title>Deleting files and folders</title>
\r
17 <primary>delete</primary>
\r
20 <primary>remove</primary>
\r
25 <guimenu>TortoiseGit</guimenu>
\r
26 <guimenuitem>Delete</guimenuitem>
\r
28 to remove files or folders from Git.
\r
33 <guimenu>TortoiseGit</guimenu>
\r
34 <guimenuitem>Delete</guimenuitem>
\r
36 a file, it is removed from your working tree immediately as well
\r
37 as being marked for deletion in the repository on next commit.
\r
38 The file's parent folder shows a <quote>deleted</quote> icon overlay.
\r
39 Up until you commit the change, you can get the file back using
\r
41 <guimenu>TortoiseGit</guimenu>
\r
42 <guimenuitem>Revert</guimenuitem>
\r
44 on the parent folder.
\r
49 <guimenu>TortoiseGit</guimenu>
\r
50 <guimenuitem>Delete</guimenuitem>
\r
52 a folder, it remains in your working tree, but the overlay
\r
53 changes to indicate that it is marked for deletion.
\r
54 Up until you commit the change, you can get the folder back using
\r
56 <guimenu>TortoiseGit</guimenu>
\r
57 <guimenuitem>Revert</guimenuitem>
\r
59 on the folder itself.
\r
60 This difference in behaviour between files and folders
\r
61 is a part of Git, not TortoiseGit.
\r
64 If you want to delete an item from the repository, but keep it
\r
65 locally as an unversioned file/folder, use
\r
67 <guimenu>Extended Context Menu</guimenu>
\r
68 <guimenuitem>Delete (keep local)</guimenuitem>
\r
70 You have to hold the <keycap>Shift</keycap> key while right clicking on
\r
71 the item in the explorer list pane (right pane) in order to see this
\r
72 in the extended context menu.
\r
75 If a <emphasis>file</emphasis> is deleted via the explorer
\r
76 instead of using the TortoiseGit context menu, the commit
\r
77 dialog shows those files and lets you remove them from
\r
78 version control too before the commit. However, if you update
\r
79 your working tree, Git will spot the missing file and
\r
80 replace it with the latest version from the repository.
\r
81 If you need to delete a version-controlled file, always use
\r
83 <guimenu>TortoiseGit</guimenu>
\r
84 <guimenuitem>Delete</guimenuitem>
\r
85 </menuchoice> so that Git doesn't have to guess what
\r
86 you really want to do.
\r
91 <title>Getting a deleted file or folder back</title>
\r
93 If you have deleted a file or a folder and already committed
\r
94 that delete operation to the repository, then a normal
\r
96 <guimenu>TortoiseGit</guimenu>
\r
97 <guimenuitem>Revert</guimenuitem>
\r
99 can't bring it back anymore. But the file or folder is not
\r
100 lost at all. If you know the revision the file or folder got
\r
101 deleted (if you don't, use the log dialog to find out) open
\r
102 the repository browser and switch to that revision. Then select
\r
103 the file or folder you deleted, right-click and select
\r
105 <guimenu>Context Menu</guimenu>
\r
106 <guimenuitem>Switch/Checkout...</guimenuitem>
\r
111 <sect2 id="tsvn-dug-rename-move">
\r
112 <title>Moving files and folders</title>
\r
114 <primary>rename</primary>
\r
117 <primary>move</primary>
\r
119 <?dbhh topicname="HIDD_RENAME"?>
\r
121 If you want to do a simple in-place rename of a file or
\r
124 <guimenu>Context Menu</guimenu>
\r
125 <guimenuitem>Rename...</guimenuitem>
\r
127 Enter the new name for the item and you're done.
\r
131 If you want to move files around inside your working tree,
\r
132 perhaps to a different sub-folder,
\r
133 use the right-mouse drag-and-drop handler:
\r
137 select the files or directories you want to move
\r
142 <action>right-drag</action> them to the
\r
143 new location inside the working tree
\r
148 release the right mouse button
\r
153 in the popup menu select
\r
155 <guimenu>Context Menu</guimenu>
\r
156 <guimenuitem>Git Move versioned files here</guimenuitem>
\r
164 <title>Commit the parent folder</title>
\r
166 Since renames and moves are done as a delete followed by an
\r
167 add you must commit the parent folder of the renamed/moved
\r
168 file so that the deleted part of the rename/move will
\r
169 show up in the commit dialog. If you don't commit the removed
\r
170 part of the rename/move, it will stay behind in the repository
\r
171 and when your co-workers update, the old file will not be
\r
172 removed. i.e. they will have <emphasis>both</emphasis> the old
\r
173 and the new copies.
\r
178 You can also use the repository browser to move items around.
\r
179 Read <xref linkend="tsvn-dug-repobrowser"/> to find out more.
\r
183 <title>Do Not Git Move Submodule</title>
\r
185 You should <emphasis>not</emphasis> use the TortoiseGit
\r
186 <guilabel>Move</guilabel> or <guilabel>Rename</guilabel>
\r
187 commands on a folder which has been created using
\r
188 <literal>git submodule</literal>.
\r
190 This action would cause the external item to be deleted from
\r
191 its parent repository, probably upsetting many other people.
\r
192 If you need to move an externals folder you should use an
\r
193 ordinary shell move, then adjust the
\r
194 <literal>svn:externals</literal> properties of the source
\r
195 and destination parent folders
\r
202 <sect2 id="tsvn-dug-renameincase">
\r
203 <title>Changing case in a filename</title>
\r
205 <primary>case change</primary>
\r
207 <?dbhh topicname="HIDD_RENAMEINCASE"?>
\r
209 Making case-only changes to a filename is tricky with Git
\r
210 on Windows, because for a short time during a rename, both filenames
\r
211 have to exist. As Windows has a case-insensitive file system,
\r
212 this does not work using the usual Rename command.
\r
215 Fortunately there are (at least) two possible methods to rename a file
\r
216 without losing its log history. It is important to rename it
\r
217 within Git. Just renaming in the explorer will corrupt
\r
221 Solution A) (recommended)
\r
225 Commit the changes in your working tree.
\r
230 Rename the file from UPPERcase to upperCASE directly
\r
231 in the repository using the repository browser.
\r
236 Update your working tree.
\r
247 Rename from UPPERcase to UPPERcase_ with the rename command
\r
248 in the TortoiseGit submenu.
\r
253 Commit the changes.
\r
258 Rename from UPPERcase_ to upperCASE.
\r
263 Commit the changes.
\r
271 <sect2 id="tsvn-dug-rename-case-conflict">
\r
272 <title>Dealing with filename case conflicts</title>
\r
274 If the repository already contains two files with the same name
\r
275 but differing only in case (e.g. <filename>TEST.TXT</filename>
\r
276 and <filename>test.txt</filename>), you
\r
277 will not be able to update or checkout the parent directory
\r
278 on a Windows client. Whilst Git supports case-sensitive
\r
279 filenames, Windows does not.
\r
282 This sometimes happens when two people commit, from separate
\r
283 working trees, files which happen to have
\r
284 the same name, but with a case difference. It can also happen
\r
285 when files are committed from a system with a case-sensitive
\r
286 file system, like Linux.
\r
289 In that case, you have to decide which one of them you want to
\r
290 keep and delete (or rename) the other one from the repository.
\r
293 <title>Preventing two files with the same name</title>
\r
295 There is a server hook script available at:
\r
296 <ulink url="http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/">
\r
297 <citetitle>http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/</citetitle>
\r
299 that will prevent checkins which result in case conflicts.
\r
305 <sect2 id="tsvn-dug-rename-repair">
\r
306 <title>Repairing File Renames</title>
\r
308 Sometimes your friendly IDE will rename files for you as part of a refactoring
\r
309 exercise, and of course it doesn't tell Git. If you try to commit your
\r
310 changes, Git will see the old filename as missing and the new one as
\r
311 an unversioned file. You could just check the new filename to get it added in,
\r
312 but you would then lose the history tracing, as Git does not know the
\r
316 A better way is to notify Git that this change is actually a rename,
\r
317 and you can do this within the <guilabel>Commit</guilabel> and
\r
318 <guilabel>Check for Modifications</guilabel> dialogs.
\r
319 Simply select both the old name (missing) and the new name (unversioned)
\r
322 <guimenu>Context Menu</guimenu>
\r
323 <guimenuitem>Repair Move</guimenuitem>
\r
325 to pair the two files as a rename.
\r
328 <sect2 id="tsvn-dug-rename-del-unversioned">
\r
329 <title>Deleting Unversioned Files</title>
\r
331 Usually you set your ignore list such that all generated files are ignored
\r
332 in Git. But what if you want to clear all those ignored items to produce
\r
333 a clean build? Usually you would set that in your makefile, but if you are
\r
334 debugging the makefile, or changing the build system it is useful to have a way
\r
335 of clearing the decks.
\r
338 TortoiseGit provides just such an option using
\r
340 <guimenu>Extended Context Menu</guimenu>
\r
341 <guimenuitem>Delete unversioned items...</guimenuitem>
\r
343 You have to hold the <keycap>Shift</keycap> while right clicking on a folder
\r
344 in the explorer list pane (right pane) in order to see this in the extended
\r
346 This will produce a dialog which lists all unversioned files anywhere in your
\r
347 working tree. You can then select or deselect items to be removed.
\r
350 When such items are deleted, the recycle bin is used, so if you make a mistake
\r
351 here and delete a file that should have been versioned, you can still recover it.
\r