2

Using Netbeans 7.2, How can I rename (Refactor->Rename) a class/file from Netbeans IDE so that it will be commited as a File Rename/Move and not a file "added" (and the deleted file will actually be repulled on the next pull)

xblitz
  • 663
  • 4
  • 14
  • git has no rename: `git mv` actually does an `add` and an `rm` behind the scenes, renames are "detected". You mean to say Netbeans only does the `add` and not the `rm`? What does `git status` say when you rename a file in NetBeans? – fge Feb 01 '13 at 00:46
  • When you do a "Refactor->Rename" in NetBeans, it is equivalent to using `git mv` on the command line. Are you sure that you commited the change in both the source and destination directories? – Code-Apprentice Feb 01 '13 at 00:52
  • @fge is right.. a 'git mv' is just like 'add' and 'rm' .. my problem seems that when I did my commit, I only did it on the renamed(new) file so the 'rm' was not commited. – xblitz Feb 01 '13 at 01:00
  • @xblitz if that is really the case, it looks like a serious bug in NetBeans' handling of git repos... Or did you do the commit by hand? – fge Feb 01 '13 at 01:02
  • @fge it's just a case of bad usage on my part I would say because I right clicked on the newly renamed file to do a commit (where as I should have rightclicked on the project) so I only had THAT file in the modification list.. – xblitz Feb 01 '13 at 01:05
  • Ah, OK, that makes more sense. I'd have been really surprised if this kind of bug didn't go unnoticed ;) – fge Feb 01 '13 at 01:07

2 Answers2

4

answering my own question which is actually due to bad usage on my part but might still help others...

First: git mv which is used to move/rename files actually only does rm then add to a file then you can still maintain revision history to the file by doing a git log --follow explained in this previous question

Second: when using Netbeans with git, renaming (with Refactor->Rename) a file will do the appropriate git commands but be sure to do a commit from either the project folder or Source Folder (right click in the project/file tree) that contains both the old and new file/location so that your commit includes the remove and add/rename actions for the implicated files.

Community
  • 1
  • 1
xblitz
  • 663
  • 4
  • 14
0

I know this is an old thread but just to stress on xblitx answer and to help others in future, After Refactor/Rename Right click on the package of the action -> Git -> Show Changes You should see all the actions(Delete and Renamed/Modified) Commit all of them.

Norrey Okumu
  • 21
  • 1
  • 4