5

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?

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
wanghao
  • 3,335
  • 2
  • 18
  • 13
  • At last, i commit, the `app/controllers/cpc_admin_controller.rb` and `app/helpers/admin_helper.rb` still there, The file name has not renamed. – wanghao Oct 09 '14 at 08:06

1 Answers1

7

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Thank you very much. When i read [perform rename detection using a heuristic](http://stackoverflow.com/a/21292993/6309), i reappear my issue. – wanghao Oct 09 '14 at 10:26