vscode icon indicating copy to clipboard operation
vscode copied to clipboard

When renaming a file, rename it using git if in a repository

Open stereokai opened this issue 10 years ago • 12 comments

  • VSCode Version: 1.0.0
  • OS Version: OS X El Capitan

Steps to Reproduce:

  1. Rename a file via the sidebar

Expected result:

  • Git registers the rename (ie. when using git mv)

Actual result:

  • Git doesn't recognize the operation as a rename, but rather thinks the file with the old name was deleted, and the renamed file appears untracked.

stereokai avatar May 05 '16 09:05 stereokai

@stereokai not if you stage the change though, right?

bpasero avatar May 05 '16 10:05 bpasero

@bpasero Well, if you git mv any file, it gets staged consequently. Is that what you mean?

This behavior is present in WebStorm by default, for example.

stereokai avatar May 05 '16 11:05 stereokai

@stereokai yeah so git typically is smart enough to detect a rename even if you do it from the file system as soon as you stage the change. Otherwise any 3rd party tool that is not aware of git would not cause a git mv in the end.

bpasero avatar May 05 '16 11:05 bpasero

@bpasero Well, as I described, unfortunately with VSCode git doesn't recognize a rename.

To be clearer, once I stage a VSCode rename, it doesn't show as a rename in git, but as a deletion and a new file.

stereokai avatar May 05 '16 11:05 stereokai

@stereokai makes sense, I think this only happens though if the 2 files have so many changes that git does not recognize they are the same.

bpasero avatar May 05 '16 16:05 bpasero

No changes, only rename

Try for yourself :) On May 5, 2016 7:02 PM, "Benjamin Pasero" [email protected] wrote:

@stereokai https://github.com/stereokai makes sense, I think this only happens though if the 2 files have so many changes that git does not recognize they are the same.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/Microsoft/vscode/issues/6127#issuecomment-217195190

stereokai avatar May 05 '16 16:05 stereokai

Is someone working on it ?

lironess avatar Jan 12 '17 13:01 lironess

I am strongly opposed to the IDE making any implicit changes to the staging area of my git repositories (i.e. the index). I frequently use it as a scratchpad that I compare against, and when an IDE makes changes to it in the background I have lost work, incorrectly committed files, and/or been unable to correctly review my local progress. Three operations in an IDE which I expect to be able to complete without affecting the staging area of a Git repository are:

  1. Deleting a file in the Explorer view (or equivalent in other IDEs)
  2. Renaming a file in the Explorer view
  3. Adding a file in the Explorer view

Note that Git is not like Subversion where file renames need to be tracked using special commands for it to work. The git-mv command does not have any impact on the ability/behavior of Git in tracking renamed files. The only thing it does is automatically update the staging area (index) rather than waiting for a user to do it explicitly.

sharwell avatar Jan 12 '17 13:01 sharwell

The same problem to me. VSCode version: 1.11.2. Windows 10

rodison avatar May 04 '17 11:05 rodison

I have the same problem. VSCode version: 1.11.2. Windows 10

radziksh avatar May 04 '17 17:05 radziksh

@stereokai @rodison @lironess I had the same problem until I realized that the git does not erase the history of the changes anyway, no matter that the file is shown as deleted and created again. The history of changes will not be lost. So there is no more problem for me.

radziksh avatar May 04 '17 17:05 radziksh

@radziksh Thanks for that link. It actually makes it clear the git mv does nothing special, and it's all in the hands of Git to be aware of file renames. Thanks!

stereokai avatar May 05 '17 06:05 stereokai