user32882
user32882

Reputation: 5927

Git checkout issues

I would like to perform something similar to an svn update operation with git. I have a remote repository which originates from a fork operation on a master repository. I cloned this remote repository and now have a local repository.

I started working in this local repository and modified some files, added some files and deleted some files. I have committed/staged nothing at this point. I would like to come up with a generic command which will allow me to revert the state of my local repository to how it is in my remote forked repository, but without deleting the files I added. More specifically, the operation (similar to an svn update should:

I thought that this was within the realm of the git checkout. When I run git checkout it shows that the files are added, deleted or modified, but when I run a git status again I get the same as what I got before running git checkout. Also browsing through my local repo I see that that deleted files are not added again.

Am I using git checkout wrong? Why doesn't my local repo go back to what it was before?

Upvotes: 0

Views: 538

Answers (1)

ikkentim
ikkentim

Reputation: 1658

If you have not yet staged the new files, the files are untracked. Untracked files will not be removed when resetting. You can reset using:

git reset master --hard

Please note hard resetting can be a little scary, make real sure you have no tracked changes you wish to keep!

See also: git reset --hard HEAD leaves untracked files behind

Upvotes: 1

Related Questions