-
Notifications
You must be signed in to change notification settings - Fork 196
Git Workflow
Paul Jewell edited this page Sep 1, 2016
·
5 revisions
- To get started sign up for an account on Bitbucket
- Fork the main repository
- Now you can clone your fork using the https or ssh protocol (see TODO:). e.g.
git clone https://[email protected]/YOUR_BB_USERNAME/librepilot.git
for https which is the easiest to set up. - Next add the main LibrePilot remote
git remote add upstream https://bitbucket.org/librepilot/librepilot.git
, you can use anything that makes sense instead ofupstream
, I simply usebb
to keep the length down.
Optional
- You shouldn't need a
next
branch in your fork sogit fetch upstream
git branch --set-upstream-to=upstream/next next
git push origin --delete next
- Get the latest from upstream
git fetch upstream
- Now start you branch e.g.,
git checkout -b LP-XX_branch_name upstream/next
- Make some changes and
git add files
, double check what you are committinggit diff --cached
- Now commit
git commit
. Refer to the Jira id in the commit message: "LP_XX ...". This will ensure the commit is picked up by Jira and linked to the original issue. - . . . Probably some more commits
- Once you have finished working on the branch, you are now ready to push it to your fork but there is an extra step you should do to keep things tidy and up to date with the latest LibrePilot so there are no merge conflicts.
git fetch upstream
git rebase --interactive upstream/next
This gives you the chance to also amend/fixup/squash/reword/reorder any commits if you want. Rebasing can initially by daunting but it is an essential git skill so it is worth learning the ins and outs of it. Remember if you get into trouble you can alwaysgit rebase --abort
and ask for help. - Now push it to your fork
git push -u origin HEAD
- Now you can create a pull request at the main repository
- To quickly checkout out someone's work do
git fetch https://bitbucket.org/THEIR_USERNAME/librepilot.git <branch_name> && git checkout FETCH_HEAD
- If you are likely to be reviewing this users work a lot you can add their fork as a remote to save using the full URL each time e.g.,
git remote add <dev's_name> https://bitbucket.org/THEIR_USERNAME/librepilot.git
and then each time just dogit fetch <dev's_name> && git checkout <dev's_name>/<branch_name>