Skip to content

Instantly share code, notes, and snippets.

@danialkalbasi
Last active March 1, 2017 16:58
Show Gist options
  • Save danialkalbasi/92842ca5ffbe7d847563f51104625a6a to your computer and use it in GitHub Desktop.
Save danialkalbasi/92842ca5ffbe7d847563f51104625a6a to your computer and use it in GitHub Desktop.
git rebase and reset
/*
** When you fix all the issues based on the comment, do a rebase
*/
git rebase master
/*
** Now copy the files that you changed and keep the copy somewhere.
** Open your Terminal and find the git commit that you want to reset to (most probably it's your first commit)
*/
git reflog
/*
** Now use the commit code here!
*/
git reset --hard <SOME-COMMIT>
/*
** Now do a rebase from your master
*/
git rebase master
/*
** Everything should be fine. Now replace your files copy and commit your changes but don't push
** Finally we need to do a force push
*/
git push origin +branchName
/*
** That's it! Now you only have one commit and also have the latest master changes.
** Your git software might show pull and push items but don't pull or push after your force push!
*/
/*
** If you still get a comment in your pull request, here it's a simple solution to amend your changes
** Do your changes
*/
git add .
git commit --amend
git push origin +branchName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment