Git workflow with remote branch and fork...

in #git4 years ago (edited)

Developers work differently with git. Some prefer to work directly off the main repo and create their own branch, merge it with master after committing the work. On the other hand, there are professionals in our field, who insist on forking the main repo and then work from the forked repo. Once dev branch in the forked repo is committed, then push those changes to original repo's dev branch.

Developers work differently with git. Some prefer to work directly off the main repo and create their own branch, merge it with master after committing the work. On the other hand, there are professionals in our field, who insist on forking the main repo and then work from the forked repo. Once dev branch in the forked repo is committed, then push those changes to original repo's dev branch.

Here are steps one can take to achieve the workflow using git and remote branches:
Step 1) Checkout new branch git checkout -b new-branch
Step 2) Make changes
Step 3) Add to git git add .
Step 4) Commit git commit -m "Made changes!" or git commit -a
Step 5) Push to your repo git push origin new-branch
Step 6) Make PR from pushed branch
Step 7) Merge into dev after it passes tests
http://jenkins.corp-domain.local/job/AwesomeProject0/
Click "Scan Repository Now"
Step 8) Make PR from dev into master
Step 9) Merge dev into master once tests pass
Step 10) Update local copy and remote fork
git checkout master -> git pull upstream master -> git push origin master
git checkout dev -> git pull upstream dev -> git push origin dev

Rebase/Upstream

git remote add upstream https://github.corp-domain.com/DataScienceSourceCode/AwesomeProject0.git
git remote -v
git fetch upstream
Check out your fork’s local master branch by issuing git checkout master
Merge the changes from upstream/master into your local master branch by issuing git merge upstream/master
git push