Skip to content

Git Flow

Sean Quigley edited this page Aug 18, 2016 · 8 revisions

Working locally

You should fork this repo. Here is an example of my fork. Next you should clone your fork locally to do your work.

$ git clone [email protected]:seanpquig/study-group.git
Cloning into 'study-group'...

Then you can make changes and commit them locally

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")

$ git add README.md

$ git commit -m 'my changes'

Pushing changes to your own remote copy

This is for pushing your local changes up to your own fork hosted on GitHub. Command for checking information on remotes:

$ git remote -v
origin	[email protected]:seanpquig/study-group.git (fetch)
origin	[email protected]:seanpquig/study-group.git (push)

Push changes

$ git push origin master

Sharing with the Upstream the-deep-learners repo

Before you send changes to the upstream fork, you need to add it as another remote repository.

$ git remote add upstream [email protected]:the-deep-learners/study-group.git

Now you can see your own fork origin and the upstream fork called upstream (it doesn't have to be named that FYI).

$ git remote -v
origin	[email protected]:seanpquig/study-group.git (fetch)
origin	[email protected]:seanpquig/study-group.git (push)
upstream	[email protected]:the-deep-learners/study-group.git (fetch)
upstream	[email protected]:the-deep-learners/study-group.git (push)

It is safest and best practice to pull in the latest changes from the upstream fork before you try to share your own changes with it.

$ git pull upstream master

For sharing changes with an upstream fork, a very safe and commonly used practice in the Open Source community is via opening a pull request to merge in your changes. First push to your own remote fork:

$ git push origin master

Now go the homepage of your repo on GitHub, and click the New pull request button. Then select your base and head forks and branches in the UI like so:

pull_request

Click Create pull request which will prompt someone maintaining the upstream fork to review your changes and merge them into the upstream codebase.

Clone this wiki locally