Reputation: 9476
When I am trying to pull from git,getting below error
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
I have tried to stash changes but after stash pull is not working, asking for merge.
How can I pull changes without commiting/adding existing?
Upvotes: 10
Views: 38002
Reputation: 4765
Try with below Command:
git fetch origin
git reset --hard origin/master
git pull
Upvotes: -1
Reputation: 149
First backup the conflicted files!
Then execute:
git fetch origin
git reset --hard origin/master (or your branch name)
This way you should get the full git repository code if you want restore conflict file or compare them.
Upvotes: 12
Reputation: 1436
Isn't it because you have an ongoing merge? Have you done
$ git merge --abort
This will cancel the merge that was ongoing. After that, you should be able to pull. The pull might induce a new merge if some conflicts are found. Be aware that the "merge abort" will cancel any modification made in the context of the merge.
Upvotes: 9
Reputation: 3112
You can get around this by checking out a new branch and committing your changes there. Then you can force update the main branch from your remote as intended, and work on merging the code locally. But this is why doing new work in its own branch is ideal.
Upvotes: 0
Reputation: 1607
To preserve your changes as well , Commit or stash your changes first, there are some files which have conflicts. Install kdiff3 as a merge tool from the following link
When you do a git pull now, the console will show changes, type git mergetool -y
and merge the changes manually.
Upvotes: 3
Reputation: 314
I'm not sure what you want to do, but if its pulling and removing your changes, then git reset is what you need to do.
See: http://git-scm.com/docs/git-reset
What you want is probably
git reset --hard
Be warned, this will remove any changes you made to your files!
Afterwards, the pull should work.
Upvotes: 1