Skip to content

Instantly share code, notes, and snippets.

@nopjia
Last active August 29, 2015 14:07
Show Gist options
  • Save nopjia/98ecb43c3de07de3ad38 to your computer and use it in GitHub Desktop.
Save nopjia/98ecb43c3de07de3ad38 to your computer and use it in GitHub Desktop.
Git Workflow

Git Workflow

Resources

Workflow

  • We follow the Feature Branch Workflow.
  • All code modifications are done in their own dedicated branch.
  • When the new code is ready, a code review is given. Any code review back and forth are done in the feature branch.
  • Finally, the new code branch is merged back into master.

Making a new feature branch

  git checkout -b new-feature     # make a new branch
                                  # make changes
  git commit -am "my message"     # commit changes
  git push origin new-feature     # push to new remote branch
                                  # (only first time pushing)

Prepare feature branch for merge into master

This is to update the feature branch (both local and remote) with the latest changes from master and to eliminate any merge conflicts when merging back into master.

  git checkout new-feature        # go to feature branch
  git merge master                # merge master into this branch
                                  # fix any merge conflicts
  git commit                      # commit the merge
  git push                        # push to remote branch

Merge feature branch into master

This can be done by a different person, for example, the code reviewer who approved the branch. (Note: This assumes the remote feature branch is up-to-date from the previous step.)

  git checkout master             # go to master
  git pull                        # make sure your local master is up-to-date
  git pull origin new-feature     # merge remote feature branch into local master
  git push                        # push local master to remote master

Post-merge clean up

The feature branch (both local and remote) are now completely merged into master and have no more unique changes in them so it is now safe to delete them.

  git checkout master             # go to master (get out of that feature branch)
  git branch -d new-feature       # delete local feature branch
  git push origin :new-feature    # delete remote feature branch

Nop Jiarathanakul, nop@storm8.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment