John Fred Fadrigalan
John Fred Fadrigalan

Reputation: 203

how to unstage a renamed file in git index?

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.

Upvotes: 10

Views: 5000

Answers (1)

Maximillian Laumeister
Maximillian Laumeister

Reputation: 20359

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.

Upvotes: 15

Related Questions