2009-10-14 38 views
22

本地刪除一個文件,然後是svn update,恢復該文件的本地副本。但是,這似乎不適用於文件夾。有什麼辦法可以讓它對文件夾起作用嗎?如何恢復本地刪除的文件夾?

編輯: 這是控制檯輸出的樣子:

C:\svn\Google Project Hosting\xulwin\xulrunnersamples>rmdir /S /Q treeview 

C:\svn\Google Project Hosting\xulwin\xulrunnersamples>svn up 
D treeview 
Updated to revision 50. 

EDIT2: 我已經使用SVN超過兩年,現在和以前我從來沒有過這樣的錯誤。但我沒有改變任何設置。我能想到的唯一事情就是我今天在外部硬盤驅動器上創建了一個帶有Tortoise SVN的本地存儲庫,以備份一些不相關的舊東西。但是這不應該是問題的原因,因爲這種行爲既出現在本地存儲庫的本地副本上,也出現在Google Project Hosting的代碼中。

編輯3: WTF我突然無法再現錯誤了。這一切都像現在這樣。但我沒有改變任何東西。

EDIT4: 在EDIT1文件似乎被標記爲已刪除,但它不是因爲svn commit命令什麼都沒做。烏龜檢查修改任何東西都沒有。

注意:當問題仍然存在時,完全遞歸更新將恢復該文件夾。

+0

您是否嘗試過使用Git? –

回答

65

我今天用svn 1.5.6遇到了這個問題。 svn up --force the_dir_path爲我修好了。

要重新創建:

$ svn up 
Updated to revision X. 
$ rm -rf the_dir_path 
$ svn up 
D the_dir_path 
Updated to revision X. 
$ svn up 
Updated to revision X. 
$ svn up --force the_dir_path 
A .... 
A .... 
Updated to revision X. 
+0

對於所有嘗試直接輸入'dir'(像我一樣)的人來說,它應該被替換爲你想要返回的實際目錄 –

+7

這是唯一解決它的答案。回覆,遞歸回復等都不起作用。謝謝! – Laurent

+0

感謝您節省我:) – Stevko

14

您可能想要使用svn revert命令,而不是通過刪除項目然後更新以恢復它們的過程。使用-R開關以遞歸方式恢復文件/目錄。

的復歸SVN幫助信息如下:

revert: Restore pristine working copy file (undo most local edits). 
usage: revert PATH... 

    Note: this subcommand does not require network access, and resolves 
    any conflicted states. However, it does not restore removed directories. 

Valid options: 
    --targets ARG   : pass contents of file ARG as additional args 
    -R [--recursive]   : descend recursively, same as --depth=infinity 
    --depth ARG    : limit operation by depth ARG ('empty', 'files', 
          'immediates', or 'infinity') 
    -q [--quiet]    : print nothing, or only summary information 
    --changelist ARG   : operate only on members of changelist ARG 
          [aliases: --cl] 

Global options: 
    --username ARG   : specify a username ARG 
    --password ARG   : specify a password ARG 
    --no-auth-cache   : do not cache authentication tokens 
    --non-interactive  : do no interactive prompting 
    --trust-server-cert  : accept unknown SSL server certificates without 
          prompting (but only with '--non-interactive') 
    --config-dir ARG   : read user configuration files from directory ARG 
    --config-option ARG  : set user configuration option in the format: 
           FILE:SECTION:OPTION=[VALUE] 
          For example: 
           servers:global:http-library=serf 
+2

刪除一個文件夾,然後是svn更新是清理該文件夾內的垃圾/臨時文件的一種便捷方式。 – StackedCrooked

+0

如果文件夾遭到破壞,那麼只需刪除和恢復它就比試圖修復它快。 – StackedCrooked

+7

恢復不會重新創建刪除的文件夾 – Damien

5

使用svn revert (-R) foldername把它帶回來。你已經使用svn rmsvn up刪除它,svn up不會爲你重新創建它,因爲它仍然被標記爲已刪除

+0

他沒有'svn rm',只是'rm'。我也有這個問題,恢復沒有解決它。只有'update --force'。 – Laurent

+0

@Laurent,謝謝(如果你仍然在這裏),如果你有這個答案,我會投這個票。 – 244an

3

我用不小心刪除的文件夾命令

SVN UPDATE

在父文件夾

0
svn status|grep ^D|^Ct -c9-|xargs -n1 svn revert