Skip to content

Instantly share code, notes, and snippets.

@miss-invincible
Last active February 27, 2017 15:48
Show Gist options
  • Save miss-invincible/66437e680badfd09828b8bf930e5798e to your computer and use it in GitHub Desktop.
Save miss-invincible/66437e680badfd09828b8bf930e5798e to your computer and use it in GitHub Desktop.
when u commit and then realize that yo have not pulled from remote.Follow these steps to avoid adding an extra merge commit to your branch and keep the commits clean.

Say the branch in which you were working was : master

git add -A
git commit -m "added few changes"
commit hash = 5e108f2

you added your work and then committed it. But then realised you forgot to pull.Now:
git checkout -b newtry master
// git checkout newtry -->optional : try without this

git branch -d master /git branch -D master (force delete)

git pull origin master

git checkout master

git cherry-pick 5e108f2

git push origin master

git branch -d newtry/git branch -D newtry

@aniket03
Copy link

Great post @miss-invincible !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment