6/16/2018 - 4:27 PM

git workflow: develop a new feature

# Reset local branch master with the remote branch master
git fetch <remoteName>
git checkout master
git reset --hard <remoteName>/master

# Create a new branch. Format: dev = feature/ticketNumber-FeatureDescription
git branch dev
# Switch to new branch
git checkout dev
# shorthand: git checkout -b dev

# Develop the feature...
# If ok, create a PR.
# Make sure your dev branch is up-to-date with latest changes on remote master
git rebase <remoteName>/master
# While rebasing you can encounter conflicts. 3 options:
git rebase --abort # Completely undo the rebase
git rebase --skip # Do not include changes introduced byu the commit ==> rare
git rebase --continue # After you fixed the conflict!

# When done rebasing, force push to update the remote dev
git push -f

# Ask your teammates to review your code...
# If ok, merge the dev branch to the remote staging branch
git checkout staging
git pull
git merge dev
git push

# And then deploy to validation server...
# If ok, merge the master PR
git checkout master
git pull
git merge staging
git push