Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column
width70%

Getting set up

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  e.g.

Code Block
git clone https://YOUR_BB_USERNAME@bitbucket.org/YOUR_BB_USERNAME/librepilot.git

for https which is the easiest to set up.

Next add the main LibrePilot remote, you can use anything that makes sense instead of upstream, I simply use bb to keep the length down.

Code Block
git remote add upstream https://bitbucket.org/librepilot/librepilot.git

Optional

You shouldn't need a next branch in your fork so:

Code Block
git fetch upstream
git branch --set-upstream-to=upstream/next next 
git push origin --delete next
Column
width30%
Panel
titleIn this page
Table of Contents

Starting some work

Section
Column
width70%

Get lasted

Get the latest from upstream

Code Block
git fetch upstream



Create new branch

Now start your branch, the LP-XX refers to the JIRA ticket you pick for your work:

Code Block
git checkout -b LP-XX_branch_name upstream/next



Make changes

Make some changes and 'git add files', double check what you are committing 'git diff --cached'
Before adding files, the files changed can be displayed using 'git status'


Commit

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 add some more changes /  commits


Rebase

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.

Code Block
git fetch upstream
git rebase --interactive upstream/next 
Info

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 always 'git rebase --abort' and ask for help.



Push your code

Now push it to your fork

Code Block
git push -u origin HEAD




Column
width30%


...

Create a pull request

Section
Column
width50%

Now you can create a pull request at the main repository

Go to the personal repository page (eg. https://bitbucket.org/YOUR_NAME/librepilot/, open the left menu  and choose "Create pull request"

Column
width50%

...

Section
Column
width50%


Choose the branch you want to use for the pull request (from your repo) and the destination branch in main (Librepilot) repository, usually the next branch or a release branch. NEVER  branch

Add a title starting with LP-XX so the pull request is linked with JIRA issue.

Add a description about the changes / commits

Choose 'Close LP-XX after the pull request is merged'

Create pull request.


Column
width50%


...

Reviewing someone's work

Section
Column
width70%

To quickly checkout out someone's work do:

Code Block
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 you can add the remote repo:

Code Block
git remote add <dev's_name> https://bitbucket.org/THEIR_USERNAME/librepilot.git

and then each time just do:

Code Block
git fetch <dev's_name> && git checkout <dev's_name>/<branch_name>

Where <dev's_name> is the remote repository name you choose.

Column
width30%


...