svn delete, move and rename

Delete, move and rename

Subversion allows renaming and moving of files and folders. So there are menu entries for delete and rename in the TortoiseSVN submenu.

Figure 4.33. Menu Navigation for Version Controlled Files

Menu browsing of versioned files

 

Deleting file/folder

Use TortoiseSVN → Delete to remove files or folders from Subversion.

When you TortoiseSVN → Delete a file or folder, it is removed from your working copy immediately as well as being marked for deletion in the repository on next commit. The item's parent folder shows a modified” icon overlay. Up until you commit the change, you can get the file back using TortoiseSVN → Revert on the parent folder.

If you want to delete an item from the repository, but keep it locally as a non-versioned file/folder, you can use the Extended context menu → Delete (keep local copy). In order to see the extended right-click menu, you must hold down the Shift key when you right-click on an item in the file manager's list pane (right pane) .

If an item is deleted via the explorer instead of using the TortoiseSVN context menu, the commit dialog shows those items as missing and lets you remove them from version control too before the commit. However, if you update your working copy, Subversion will spot the missing item and replace it with the latest version from the repository. If you need to delete a version-controlled file, always use TortoiseSVN → Delete so that Subversion doesn't have to guess what you really want to do.

Retrieve deleted files or directories

If you delete a file or directory and have committed the deletion to the repository, a regular TortoiseSVN → Revert can no longer retrieve it. But the file or directory is not completely lost. If you know the version of the file or directory that should be deleted (if not, use the log dialog to find out), open the data warehouse browser and select that version. Then select the file or directory you deleted, right-click and select Context Menu → Copy To... as the target to perform the copy operation, then select the path to your working copy.

Move files and folders

If you just want to rename the file or folder, use Context Menu→ Rename... to enter a new name for this entry.

If you want to move the file in the working copy, for example to a different subfolder, then drag with the right mouse button:

  1. Select the file or directory you want to move

  2. Drag them with the right mouse button to their new location in the working copy

  3. release the right mouse button

  4. From the pop-up menu, select Context Menu → SVN to move the version control entry to the current location.

Submit parent directory

Since both rename and move are performed like add followed by delete, you must commit the parent folder of the renamed/move file, so the delete part of the rename/move will appear in the commit dialog. If you don't commit the renamed/moved deleted part, it will remain in the repository and the file won't be deleted when your peers update the working copy. For example, they will have two copies, one old and one new.

You must commit immediately after renaming the folder, and don't change any files in the folder before committing, or your working copy will be really messed up.

Another way to copy or move files is through the Windows copy/move command. First select the file you want to copy, right-click in Explorer and select Context Menu→ Copy. Then go to the destination folder, right-click and select TortoiseSVN → Paste. For moving files, choose Context Menu → Cut instead of Context Menu → Copy.

You can also use the repository browser to move items around in the repository. Read the "Repository Browser" section for more information.

Don't use SVN to move external connections

You should not use TortoiseSVN's move or rename commands on directories svn:externalscreated with . Because this action may cause the external element (item) to be removed from its parent repository, which may annoy others. If you need to move an external directory, you should use the normal shell move, then adjust the svn:externalsproperties .

Handling file name case conflicts

TEST.TXTIn case you have two files with the same name but different spellings (eg: and ) in your repository test.txt, you cannot update or check out the directory containing the file on the Windows client. While Subversion supports case-sensitive filenames, Windows does not.

It happens occasionally when two people commit on separate working copies with the same file name, only different case. It also occurs when committing files in systems with case-sensitive filesystems, such as Linux.

If that's the case, you have to decide which files in this repository you want to keep and which ones to delete (or rename)

Prevent two files with the same name

There is a server hook script available at: https://svn.apache.org/repos/asf/subversion/trunk/contrib/hook-scripts/ that will prevent checkins which result in case conflicts.

Repair file rename

Sometimes your IDE will rename files because of reflection, but it can't tell Subversion of course. If you try to commit the changes, Subversion will notice that the old files are missing and new files that are not versioned are added. You can simply add new files, but you will lose the history because Subversion doesn't know the relationship of these files.

A better approach is to inform Subversion that this is actually a rename, which you can do in the Commit and Check Changes dialog. Simply select the old file (lost) and the new file (unversioned), use the right-click menu→ Repair and move the settings. These two files are renamed.

Delete unversioned files

Usually you can set your own ignore list in Subversion, eg ignore all generated files. But how do you clean up these ignored projects, resulting in a clean build? Normally you clean up in the makefile, but if you're debugging the makefile, or modifying the build system, then having a cleanup method is extremely useful.

TortoiseSVN offers to clean up the working copy using Extended Context Menu → Delete Unversioned Items... . You can see this context menu by holding down Shift when you right-click on a directory. It will bring up a dialog listing all unversioned files in the working copy. You can select or cancel deleted items.

When deleting these items, the trash can was used. So if you make a mistake and delete a file that should be version controlled, you can still recover.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325261797&siteId=291194637