Skip to content

Instantly share code, notes, and snippets.

@NicolasRitouet
Last active August 29, 2015 14:11
Show Gist options
  • Save NicolasRitouet/1305450e5d67ce97a3d2 to your computer and use it in GitHub Desktop.
Save NicolasRitouet/1305450e5d67ce97a3d2 to your computer and use it in GitHub Desktop.
Git workflow for a nice PR on github

Development phase

For open source projects, it's important to keep the history tree as clean as possible. A clean history tree will facilitate an eventual rollback. Having an easy way to rollback PR means that you can accept more PR.

  1. fork the project https://github.com/deployd/deployd/fork
  2. Define upstream as new remote git remote add upstream git@github.com:deployd/deployd.git
  3. create a new branch git checkout -b feature
  4. add your changes
  5. add tests
  6. commit (multiple times if necessary) git add . && git commit -m "Fix: ..."
  7. make sure that the tests are working
  8. squash all your commits into one git merge --squash feature
  9. push your commits
  10. Make sure you're in sync with upstream git pull --rebase upstream $branch
  11. create a pull request on github
  12. Add new commits in response to comments
  13. Squash your commits into one git merge --squash feature

Merge phase

  1. Fetch from upstream git fetch upstream pull/$PR/head:$BRANCH
  2. Checkout the branch git checkout $BRANCH
  3. Rebase ```git rebase origin/master````
  4. If the PR contains multiple commits, squash them git rebase --interactive HEAD~2 (2 being the number of commits to squash)
  5. Change the commits to squashpick b76d157 b pick a931ac7 c into pick b76d157 b a a931ac7 c
  6. run the tests
  7. Push the commits git push upstream $BRANCH:master
  8. Close the PR with the message landed as $COMMIT_SHA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment