Jean
Jean

Reputation: 22755

Force GIT Pull without commiting

I do a

git pull

and I get merge conflicts. I resolve the merge conflicts manually and issues a pull again but Git refuses to do it as Git is still thinking that there are merge conflicts.

Is there any way to force Git to perform a pull again and make it look for “diffs” (if any ) from the head(without committing the changes I made) ?

Upvotes: 4

Views: 14327

Answers (4)

Giorgio Previtera
Giorgio Previtera

Reputation: 393

In addiction, after pulled, merged and committed, you can also try (assuming your remote is 'origin', of course)

git remote show origin

It's very reassuring for me!

Upvotes: 0

Joel
Joel

Reputation: 2966

You have to commit your changes after you resolve the conflicts and push them back. Usually instead of using git pull I do a git fetch followed by a git merge and then git commit. This will only fetch the upstream changes, allow you manually merge and resolve conflicts, then commit them locally. When you're ready push the changes back to upstream.

If you use this workflow you could:

git fetch
git merge 
#resolve conflicts
git commit
git fetch #check for new changes
#eventually
git push

Upvotes: 3

Dan Ray
Dan Ray

Reputation: 21903

The process here is:

git pull

You get a notice of conflicts. You use whatever you use (though hopefully you've hooked up everything you need to use git difftool locally...

Once the conflicts are resolved, you now have a working directory that contains the merged of the remote changes and your local changes. The ONLY thing that's different is, git couldn't do the merge on its own and needed your help.

You now

git commit

to create a new commit in your local repo that is the sum of the pulled-in remote changes and your local changes. Then you

git push

to publish your changes, nicely merged up, with the remote head.

Upvotes: 0

Lily Ballard
Lily Ballard

Reputation: 185871

Why are you issuing a second git pull after fixing the merge conflicts from the first? That makes no sense. Once you fix the merge conflicts, you want to git commit instead, which will create the merge commit that merges the remote branch with your local one (and includes your conflict resolutions).

Upvotes: 4

Related Questions