-
Fork an upstream repo -- I'll use terraform-provider-vault as an example.
-
Clone your forked copy of the repo:
git clone [email protected]:elasticdog/terraform-provider-vault.git cd terraform-provider-vault/
-
Add the upstream repo as a remote:
git remote add upstream https://github.com/terraform-providers/terraform-provider-vault.git git fetch upstream
-
By default, always push to
origin
(your forked copy) using the current branch name:git config remote.pushdefault origin git config push.default current
-
Prevent accidental commits directly on the master branch using a
pre-commit
hook:$ cat .git/hooks/pre-commit #!/usr/bin/env bash current_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||') if [[ $current_branch = 'master' ]]; then echo 'Direct commits to the master branch are not allowed.' exit 1 fi
-
Set your local master branch to track
upstream/master
:git branch master -u upstream/master
-
Create a branch
whizbang
off of upstreammaster
to work on a new feature, and check out the branch:git checkout -b whizbang upstream/master
This Gist, "Git Triangular Workflow" is provided under the terms of the MIT License.
Copyright © 2018, Aaron Bull Schaefer.
These simplified instructions were inspired by Git 2.5, including multiple worktrees and triangular workflows © 2015 by Michael Haggerty.