git状态显示重命名,但不正确 [英] git status shows rename but it's incorrect
问题描述
cpc_admin_controller.rb
的控制器,完整路径是 app / controllers / cpc_admin_controller.rb
,以及一个名为helper admin_helper.rb
完整路径是 app / helpers / admin_helper.rb
。然后我从 admin_helper.rb
删除一个方法到 cpc_admin_controller.rb
,并保存,使用git来提交。 p> 但git显示如下信息
#要提交的更改:
#(使用git reset HEAD< file> ...停用)
#
#改名为:app / helpers / admin_helper.rb - > app / controllers / cpc_admin_controller.rb
#modified:app / helpers / admin_helper.rb
我认为它应该显示两个这样的修改,而不是重命名的
#要提交的更改:
#(使用git reset HEAD< file> ...以取消)
#
#modified:app / controllers / cpc_admin_controller.rb
#modified:app / helpers / admin_helper.rb
有人可以帮助我,告诉我为什么?
如此主题
$ b
Git不关心单个文件或重命名,它跟踪整棵树。
它显示为重命名只是基于这两个文件的内容的最佳猜测。
Git状态不会perform使用启发式方法重新命名检测。
但是,一旦您提交,您将看到两个文件保持分开。
I use Rails to develop. I have a controller named cpc_admin_controller.rb
the full path is app/controllers/cpc_admin_controller.rb
, and a helper named admin_helper.rb
the full path is app/helpers/admin_helper.rb
. Then I remove a method from admin_helper.rb
to cpc_admin_controller.rb
, and save, use git to commit.
But the git show the messages as follows
# 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
I think it should show two modified like this, not the renamed
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: app/controllers/cpc_admin_controller.rb
# modified: app/helpers/admin_helper.rb
Someone can help me, tell me why?
As illustrated in this thread
Git doesn't care about individual files or renames, it tracks whole trees.
What it shows as a rename is just its best guess based on the contents of the two files.
Git status does perform rename detection using a heuristic.
But once you commit, you will see the two files are kept separate.
这篇关于git状态显示重命名,但不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!