Skip to content

Instantly share code, notes, and snippets.

@veeracs
Last active October 20, 2015 20:43
Show Gist options
  • Save veeracs/56d714ba7411c803eaae to your computer and use it in GitHub Desktop.
Save veeracs/56d714ba7411c803eaae to your computer and use it in GitHub Desktop.
PR, git rebasing and squashing commits
1. Branch off of develop for a feature development/bug fix.
$ git checkout -b feature/myfeature develop
$ git checkout -b bug/CNID-1234 develop
2. Do as many commits as you want on the feature/bug branch. Once done with the changes, squash all commits into one commit
Open github and figure out how many commits to go back.
$ git rebase -i head~(number of commits)
- You can remove commits in editor by doing {command K}.
- Save!
3. Checkout develop and make sure it's up to date
$ git checkout develop
$ git pull
4. Checkout feature branch and rebase develop
$ git checkout feature/myfeature
$ git rebase develop
5. Use merge tool, resolve conflicts, and continue rebasing after diff merge
$ git status
$ git mergetool
$ git rebase --continue
5. Force Push feature branch
$ git push -f
6. Open a PR and get the code peer reviewed. After review, use Merge button on github to merge to develop
or Checkout develop and merge the feature branch
$ git checkout develop
$ git merge feature/myfeature
7. Push
$ git push
8. Delete the feature branch
$ git branch -D myfeature
Notes: If anything goes wrong abort the rebase, delete and pull the feature branch and start again.
git rebase --abort
git branch -D myfeature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment