When I do a 'git pull', I have conflict with the head commit. So I did a 'git rebase --abort'
Can I 'save' my commit to a "patch" and then do a git pull?
What I want to emulate is:
So I need somehow to 'turn back the clock'. Is that possible with git?
The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With