2013-07-25 41 views
10

我有一個具體的問題,我沒有在這裏或其他地方找到解決方案。我有一個SVN存儲庫,我正在使用git-svn來訪問它並對其進行處理。如何刪除git-svn中的空目錄?

前段時間,SVN倉庫中有一些空目錄(空的,只有子文件夾)。 Git不會跟蹤這些信息。然後將它們從SVN存儲庫中刪除。但我仍然有他們甚至跑步

git svn rebase 

後,當我用手工刪除,它們將被重新創建在接下來的

git svn rebase 

我怎樣才能擺脫他們的?

我使用純SVN進行檢查,它們不在存儲庫中。

+0

嗯,這很奇怪。 Git根本不知道或跟蹤目錄。您是否檢查過您的老闆在刪除他們時可能錯過的那些目錄中是否有舊的不可見文件?嘗試在目錄中執行'ls -la'來檢查隱藏的文件。 – Leif

+0

午夜指揮官不隱藏東西;)文件夾是空的。這可能是一個錯誤? :/ – Paladin

+0

我對Git有過很多(很多)挫折感,但我還沒有偶然發現一個合法的「bug」。我的挫折大部分原因是我缺乏理解。如果你從Git命令行執行'git status',會發生什麼?文件夾是否顯示爲「未被跟蹤」?如果你在這些目錄上執行'git ls-files directory_name --error-unmatch';它會返回「true」還是「false」?嘗試使用Git重新克隆存儲庫('git clone')以查看這些文件夾是否包含在新克隆中;也許他們只是從一個較舊的版本掛起。我只是在這裏瘋狂地猜測。 – Leif

回答

1

這是一個有點粗糙,但我發現下面的解決我的問題:

rm .git/svn/refs/remotes/trunk/unhandled.log 
git clean -df 

任何後續

git svn rebase 

不會重現什麼。

因爲我不知道如何重新生成這個文件而不重新克隆回購,我建議先做一個備份。這是一個文本文件,所以我想你也可以編輯其內容移除最終創造

+1

不要刪除'.git'中的東西。 –

11

我想你會在this blog post找到你的答案。

[...]

Remove directories from the SVN tree if there are no files left behind. SVN can version empty directories, and they are not removed by default if there are no files left in them. git cannot version empty directories. Enabling this flag will make the commit to SVN act like git. config key: svn.rmdir

To fix the root of the problem set the git config globally:

git config --global svn.rmdir true

[...]

+2

我也發現這個時Google搜索,但它不是我的問題的答案。這適用於刪除文件夾並通過git進行提交的情況。我的問題是有人通過svn刪除目錄,但我仍然在git倉庫中(但它們是空的),當我刪除它們時,它們會自動在下一個rebase上重新創建。 – Paladin

+0

我想這不是真的「正確的事情」,但也許你可以(使用Git)在文件夾中添加一個虛擬文本文件,「添加」和「提交」它們,以便它們被跟蹤然後刪除('git rm')文件並提交刪除。那麼也許你會擺脫文件夾,但它會弄髒你的歷史一點。 – Leif

+0

我可以看到老闆給我發送這個方法的地方:D – Paladin

1

讓Git svn的條目,它不應該嘗試重新創建空目錄:

git config svn-remote.svn automkdirs false 

這是手冊頁的相關章節:

svn-remote.<name>.automkdirs

Normally, the "git svn clone" and "git svn rebase" commands attempt to recreate empty directories that are in the Subversion repository. If this option is set to "false", then empty directories will only be created if the "git svn mkdirs" command is run explicitly. If unset, git svn assumes this option to be "true".

注意,很容易混淆這個話題提交/不提交空目錄SVN(這是什麼svn.rmdir是)的話題。