sublime-text-git icon indicating copy to clipboard operation
sublime-text-git copied to clipboard

Rename via Move

Open rjmoggach opened this issue 11 years ago • 6 comments

Please add a "Rename" menu option to move a file to a new file name using git mv

rjmoggach avatar Oct 02 '14 00:10 rjmoggach

:+1:

It's really frustrating to loose tracking on my files because i'm using the ide to rename rather than git mv.

I'd love to see it conditionally over ride the rename option in the side panel file browser context menu as well. :)

pjwalmsley avatar Apr 02 '15 19:04 pjwalmsley

Agree. Current workaround is to use the command 'Git: Custom Command' and write: mv <SourceFileName> <TargetFileName>

Package seems to take the working directory from the file that is opened.

For future developer. This "Git: Move", "Git: Rename" or "Git: Move/Rename" should act on the opened file.

Pendrokar avatar Feb 22 '16 14:02 Pendrokar

I do agree this would be a convenient thing to have.

That said, you shouldn't actually be losing any tracking -- git mv is literally a convenience shorthand. From the Git FAQ:

Git has a rename command git mv, but that is just for convenience. The effect is indistinguishable from removing the file and adding another with different name and the same content.

kemayo avatar Feb 22 '16 14:02 kemayo

That's correct.

By "lose tracking" I meant:

  • Running git status shows a file as deleted and a file created. I usually stage changes with "git add -u" which will pick up a rename but won't handle a creation/deletion (nice safety). Not the end of the world but it is another opportunity to hastily forget to include a file.
  • The situation kemayo mentioned; running gitk filename shows the newly created files history but not history form before the file which the new file was created from. It always logs changes by the filename they occurred on rather than grouping them (at least when viewed with gitk). Turns out I was mistaken and this is just the way git works.

pjwalmsley avatar Feb 22 '16 16:02 pjwalmsley

Hmm I did not know that. So even if a large file is renamed using 'git mv' there will be two copies of the same file somewhere in the server's repository? That sucks,

Pendrokar avatar Feb 22 '16 19:02 Pendrokar

Yea, just doesn't pair well with "git add -u". The old one is deleted and you can stage that deletion you just have to do so explicitly.

pjwalmsley avatar Feb 22 '16 20:02 pjwalmsley