Reputation: 66320
I was about to get the latest with a git pull origin master
and realized I have conflicts in some config files. But I also have other files to checkin, which I dont want to loose.
Since these conflicts are local config files, I simply deleted them, hoping to retrieve them again by doing a new pull request.
Now trying to do another git pull origin master
and it says
"Pull is not possible because you have unmerged files. please, fix them up in the work tree, and then use 'git add/rm ' as appropriate to mark resolution, or use 'git commit -a'."
So how can I recover these deleted config files with the latest state from the repository? (I didn't care about my local changes to these files, hence I deleted it)
Shall I now do for each config file:
git checkout -- path/to/individual_file
Thanks,
Upvotes: 2
Views: 1290
Reputation: 12531
If you have some files to commit you could stash them with git stash
, then reset back to the HEAD
with git reset --hard HEAD
, pull the changes with git pull
fix all the conflicts and then apply your stash on the new HEAD with git stash apply
You can also create a temporary branch
if you prefer to store your local changes, to the reset and pull on the master and the recover your local changes from the temporary branch.
Upvotes: 2
Reputation: 160833
You could do $ git reset --hard HEAD
to return the HEAD
state.
Then do git pull
again, fix the conflicts, then commit your fix.
Upvotes: 0