Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After git reset --hard HEAD, git pull still says: Untracked working tree file ... would be overwritten by merge

After git reset --hard HEAD, git pull says: Untracked working tree file ... would be overwritten by merge

any ideas?

I did try a git fetch and git fetch --all already...

like image 784
user1553189 Avatar asked Apr 25 '13 16:04

user1553189


People also ask

Will a git pull overwrite my changes?

The reason for error messages like these is rather simple: you have local changes that would be overwritten by the incoming new changes that a "git pull" would bring in. For obvious safety reasons, Git will never simply overwrite your changes.


2 Answers

If you just want to update your local to the origin's state, you could use described here solution:

$ git fetch origin

$ git reset --hard origin/master
like image 108
ephemerr Avatar answered Sep 28 '22 01:09

ephemerr


you have untracked files. Simply

git stash -u

to stow them away in the stash and get a clean work tree (-u specifies that you want to stash modifications along with new files). After you pull, merge, rebase or whatever, you can

git stash pop

to get them back.

like image 40
Adam Dymitruk Avatar answered Sep 28 '22 01:09

Adam Dymitruk