Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull says 'everything is up to date'

Tags:

git

github

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!

like image 219
Rik Nijhuis Avatar asked Dec 19 '22 20:12

Rik Nijhuis


2 Answers

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. :)

like image 179
Abibullah Rahamathulah Avatar answered Jan 02 '23 06:01

Abibullah Rahamathulah


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.

like image 39
Greg Hewgill Avatar answered Jan 02 '23 05:01

Greg Hewgill