tags:

views:

93

answers:

3

Hi,

This is the output of my 'git log'. But when I do a 'git pull' , the top commit causes conflict. So I did a 'git rebase -abort'

commit 7826b25db424b95bae9105027edb7dcbf94d6e65

commit 5d1970105e8fd2c7b30c232661b93f1bcd00bc96

But my question is Can I 'save' my commit to a patch and then do a git pull?

Just like I want to emulate * I did not do a git commit, but I did a 'git stash' instead * Do a git pull so that I should not get any merge error

So I need to somehow 'turn back the clock'. Is that possible in git?

+2  A: 

Your 7826b2 patch will still cause a conflict when it's applied after pulling, but you can do the following:

git reset --soft HEAD^
git stash
git pull
git stash pop # Will cause a conflict
git commit    # Re-commit 7826b2

Another workflow is also possible:

git reset --hard HEAD^
git pull
git cherry-pick 7826b2 # Will cause a conflict

The second workflow relies on the fact that Git keeps the 7826b2 commit in the reflog (you can think of it as the recycle bin) even though you reset the changes it introduced with the first line.

Alexander Groß
A: 

There is a way, in fact in git, I'm sure there's a multitude of ways of doing it...

You could do:

git stash     # Stash your changes
git pull      # Pull the changes
git stash pop # Pop your stash

You could do:

git pull --rebase # Bring in the changes and apply yours on top of it.

You could do:

git stash     # Stash your changes
git checkout <commit> # Pull a specific commit.
git stash pop # Pop your stash

Hope it helps.

Pran
A: 

If you did commit your changes in your local repository, you could do a straight rebase:

git fetch origin git rebase origin/master

This unwinds your local commits from the local master, applies new commits from origin/master, and then replays your local commits.

In your situation, this will result in a conflict and git will tell you which files need to be edited to resolve the conflict. After you do so, git add those files and then git commit with no arguments to recommit the changes.

Jamey Hicks