Branching - Forking Workflow

Thoughts for Forking workflow branching from fork:
Ideas taken from : https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow

Branching in the Forking Workflow

Clone your fork

git clone https://user@bitbucket.org/user/repo.git

Add the remote

git remote add upstream https://bitbucket.org/maintainer/repo

Working on the branch and pushing changes

git checkout -b some-feature
# Edit some code
git commit -a -m "Add first draft of some feature"

Fast forward merge

git pull upstream master

Making a pull request

git push origin feature-branch

 

 

More details on Clone Fork:

Make sure you have already forked:

git ls-remote repo:${str_User}/${str_Repo}
if error then
  Fork is not available - got to repo url and press fork
else
  Fork is good

Make sure there is a local clone

if ! -d git_dir/${str_User}/${str_Repo} then
  git clone
else
  There is already a local clone

Check the remote upstream

if git remote -v | grep -q "^upstream.*$StrUpstreamOrg}/${str_Repo}.git.*(push)" then
  git remote is ok
else
  git remote add upstream https://gitrepo/${str_UpstreamOrg}${str_Repo}
  git remote -v | grep -q "^upstream.*${str_UpstreamOrg}/${str_Repo}.git.*(push)" || Error "Something is wrong - maybe need git remote remove upstream and start again

Make sure there isnt already a branch of that name

if git branch | grep ${str_BranchName} then
  Warning Branch already exixts
  maybe fast forward changes from upstream
  maybe git checkout master / git fetch upstream / git pull upstream master / git push origin ${str_BranchName}
  git checkout ${str_BranchName}
else
  git checkout -b ${str_BranchName}