2014-10-12 32 views
2

我有兩個文件已經添加並在git中提交。git錯誤地將文件標記爲重命名

報告
report_dates

現在,我已經修改了兩個文件,我試圖犯下但混帳不正確標記report_dates文件改名後,我將它們添加到臨時區域。

> git status 
On branch master 
Changes not staged for commit: 
    (use "git add <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 
     modified: report 
     modified: report_dates 

> git add report 
> git add report_dates 

> git status 
On branch master 
Changes to be committed: 
    (use "git reset HEAD <file>..." to unstage) 
     renamed: report_dates -> report 
     modified: report_dates 

我嘗試使用git的承諾--dry運行,並且也顯示了文件改名驗證。將提交覆蓋原始文件?有兩個不同的文件,其中90%的內容類似。

+1

這是git的工作原理。有時如果文件內容變化太大,它不會檢測到實際的重命名。你應該接受它並繼續:) – 2014-10-12 13:29:33

+2

同樣在http://stackoverflow.com/q/26273245/6309:* commit後的git status *會起作用。 – VonC 2014-10-12 13:54:05

+0

Thanks @VonC'git commit --dry-run'將它顯示爲重命名。我還能繼續前進嗎? @AlexMDC這不是重命名,但git將其報告爲重命名。 – nshaik 2014-10-12 15:03:51

回答

2

正如我之前在「git status shows rename but it's incorrect」中所解釋的那樣,您需要在看到正確的狀態之前進行實際的提交。

一個git status承諾:

  • 仍然基於索引,它看起來像重命名已經發生了。
    有時一個git commit --dry-run -a(注意-a)可以提供幫助。
  • 檢測:
    • report_datesbeing moved(在report改名)
    • report_dates被修改

它(git status)不會知道肯定直到你真正承諾:在提交之前,您可能仍會刪除report_dates

但實際提交將註冊這兩個文件(不覆蓋),並且新的git status將不會顯示任何重命名(confirmedOP shnazz)。