Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to unstage a renamed file in git index?

Tags:

git

I'm always using git checkout <file> to unstage uncommited changes, however I can't seem to do this when files were renamed.

git just can't pickup the file I want to unstaged, tried this with no luck:

git checkout <oldfilename>

and

git checkout <newfilename>

returns error: pathspec '<file>' did not match any file(s) known to git.

like image 629
John Fred Fadrigalan Avatar asked Oct 07 '18 19:10

John Fred Fadrigalan


1 Answers

Use git reset -- newfilename to unstage the renamed file.

If instead of unstaging you are looking to rename the file back, use git mv newfilename oldfilename.

like image 149
Maximillian Laumeister Avatar answered Oct 01 '22 04:10

Maximillian Laumeister