I am working on a project with a few friends, and we are uploading everything to git. At first everything worked good, but at my local repository i deleted some files, online these files are still existing, so I tried
git pull
only, because i deleted that folders, they aren't coming back. Git says 'everything is up to date', but it isn't. Another stackoverflow-questioner had the same problem, and in a comment someone said he should use
git checkout HEAD
aand yes, there are the files i was looking for, but (I guess) that's just checking out, and they are not in my file system. How can i solve this problem?
In general: I guess there must be a command that updates everything?
Thanks!
From your comments it looks like you might have committed the deleted changes,
Try this,
git reset --hard HEAD~1
git pull origin branchname OR git checkout HEAD
Normally, git reset --hard HEAD~1
should be used with care as it will remove your local commit by one. But if you want the deleted changes and u dont care about the modifications then this is a good idea.
I hope this helps. :)
The key point that you are missing is that Git considers deleting a local file to be a modification to your working copy. As much as possible, Git tries not to undo changes that you have made to your working copy. When you run git pull
, the remote is merged into your current branch. Since there wasn't anything to do in the merge, and therefore the merge didn't affect your modified (deleted) files, Git leaves them deleted.
When you use git checkout HEAD
, you are telling Git that you want to throw away the change (undelete) the files that you deleted previously.
If you had committed the deletion of those files (therefore telling Git you wanted to keep that change), then this question would have an entirely different answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With