Git creating features

Creating features from fork

Important note

Don’t forget FIRST to create ISSUE in upstream describing the fix/feature.

Summary

These are the steps involved:

  1. Fork in Github.
  2. Clone fork locally.
  3. Set upstream.
  4. Create features/fixes in local branches.
  5. Sign commits.
  6. Push to your fork.
  7. Create PR upstream.

Fork to your own account/organization

Simple step, just press the Fork button in the top right of the GitHub repository, and select where to fork.

Clone your fork locally

Clone the default branch in the current directory:
git clone --recursive https://github.com/YOUR_ACCOUNT/YOUR_FORK.git

If you wish to clone a different branch:
git clone --recursive --branch BRANC_NAME https://github.com/YOUR_ACCOUNT/YOUR_FORK.git

If you wish to clone to a directory with a different name:
git clone --recursive https://github.com/YOUR_ACCOUNT/YOUR_FORK.git DESIRED_DIR_NAME

Set upstream repository

Set upstream (original source):
git remote add upstream https://github.com/ORIGINAL_ORGANIZATION/ORIGINAL_REPOSITORY.git

Confirm remotes:
git remote -v

> origin    https://github.com/YOUR_ACCOUNT/YOUR_FORK.git (fetch)
> origin    https://github.com/YOUR_ACCOUNT/YOUR_FORK.git (push)
> upstream  https://github.com/ORIGINAL_ORGANIZATION/ORIGINAL_REPOSITORY.git (fetch)
> upstream  https://github.com/ORIGINAL_ORGANIZATION/ORIGINAL_REPOSITORY.git (push)

In this example:
origin represents your fork repo.
upstream represents your fork’s origin.

NOTE: Names other than origin or upstream can be used. Just be careful to follow the same naming when pulling/pushing commits.

Create features/fixes

In the Autoware case , please always create new features from master branch.

Sign commits

GPG Sign

Set your GPG keys following GitHub article: https://help.github.com/en/articles/managing-commit-signature-verification

Signoff commits

Signoff your commits using git commit -s (https://git-scm.com/docs/git-commit#Documentation/git-commit.txt–s)

If you have an older git version the -s flag might not available. You can either update it via source/build/install,or use a PPA. ( Taken from https://unix.stackexchange.com/a/170831)

sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version

Update fork

git checkout master
git fetch upstream
git merge upstream/master

Create feature branch

git checkout -b feature/awesome_stuff

Push to our fork

git push origin feature/awesome_stuff

Once finished

Create PR from Github website, and target master branch.