Skip to content

Instantly share code, notes, and snippets.

@albscui
Last active September 28, 2017 04:07
Show Gist options
  • Save albscui/229cbcb088930bf32d8e2f16acaa1760 to your computer and use it in GitHub Desktop.
Save albscui/229cbcb088930bf32d8e2f16acaa1760 to your computer and use it in GitHub Desktop.

GitHub Flow Tutorial vNoBS

Here is a high-level explanation of the GitHub branch-based workflow.

Below, are step by step instructions for implementing this workflow.

1. Create a branch

You can create branches either remotely or locally.

After you create a branch remotely, you need to pull it to your local repo ...

$ git fetch origin
$ git checkout remote-branch-name

Locally, via the command-line interface recommended

Check which branch you are currently on, the * indicates the current branch ...

$ git branch
* master
some-other-branch-you-are-not-on

Checkout the master branch ...

$ git checkout master

Update local master branch ...

$ git pull origin master

Branch from master, and checkout a new local branch ...

$ git checkout -b new-feature-branch

See, now you are on the new-feature-branch, so start coding!

$ git branch
master
* new-feature-branch

2. Add commits

Alright, you've been coding for a while, and you implemented a really cool new feature. Check if there are changes in your local branch to be committed ...

$ git status

Add all changes at once ...

$ git add .

Make a commit, write a human readable message (in the present tense), and add it to the commit log ...

$ git commit -m "Adding my cool new feature!"

Push your local changes to the remote repo ...

$ git push origin new-feature-branch

If your push is rejected, then your local branch might be out of sync with the remote repo, so update your local branch first ...

$ git pull origin new-feature-branch

3. Open a Pull Request

Now that you pushed your changes to the remote repo, all the work from this point onwards should be done via the GitHub web interface.

How to create a pull request

4. Review code

The designated reviewer of the pull request should review the code, make comments, suggest changes, and after everything is done, approve the pull request.

How to approve a pull request

5. Merge

Finally, we merge our cool new feature into the master branch, and make it "official".

How to merge a pull request

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