2014-10-09 41 views
4

我使用Rails進行開發。我有一個名爲cpc_admin_controller.rb的控制器,完整路徑是app/controllers/cpc_admin_controller.rb,名爲admin_helper.rb的助手的完整路徑是app/helpers/admin_helper.rb。然後我從admin_helper.rb刪除一個方法到cpc_admin_controller.rb,並保存,使用git來提交。git status顯示重命名但不正確

但是git的顯示信息如下

# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# renamed: app/helpers/admin_helper.rb -> app/controllers/cpc_admin_controller.rb 
# modified: app/helpers/admin_helper.rb 

,我認爲它應該顯示兩個修改這個樣子,而不是改名

# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage) 
# 
# modified: app/controllers/cpc_admin_controller.rb 
# modified: app/helpers/admin_helper.rb 

有人能幫助我,告訴我爲什麼?

+0

最後,我提交了'app/controllers/cpc_admin_controller.rb'和'app/helpers/admin_helper.rb',文件名沒有重命名。 – wanghao 2014-10-09 08:06:20

回答

6

this thread

Git的說明並不關心單個文件或文件重命名,它跟蹤整個樹。
它顯示爲重命名只是基於這兩個文件的內容的最佳猜測。

Git狀態確實是perform rename detection using a heuristic
但是,一旦你提交,你會看到兩個文件保持分開。

+1

非常感謝。當我讀[執行使用啓發式重命名檢測](http://stackoverflow.com/a/21292993/6309),我再次出現我的問題。 – wanghao 2014-10-09 10:26:20