Skip to content

Instantly share code, notes, and snippets.

@Elucidation
Last active May 20, 2016 20:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elucidation/266679bc9b2a552f1e53 to your computer and use it in GitHub Desktop.
Save Elucidation/266679bc9b2a552f1e53 to your computer and use it in GitHub Desktop.
Forking/Syncing Cheatsheet

Step One - Fork Repo

Following these Forking instructions

  1. Go to main/repo and fork it from the top right.
  2. Go to your forked repo your/repo (ex. Elucidation/repo) and get the clone address.
  3. Clone it on your local machine, ex. git clone git@github.com:Elucidation/repo.git

Step Two - Sync fork to upstream

Following these Syncing a Fork instructions

  1. In your local repo, set upstream for syncing with the main repo
  2. See current remotes:
$ git remote -v
origin	git@github.com:Elucidation/repo.git (fetch)
origin	git@github.com:Elucidation/repo.git (push)

Note: replace repo with the name of the repo you're interested in

  1. Add upstream: git remote add upstream git@github.com:google/repo.git

  2. See upstream in remotes:

$ git remote -v
origin	git@github.com:Elucidation/repo.git (fetch)
origin	git@github.com:Elucidation/repo.git (push)
upstream	git@github.com:google/repo.git (fetch)
upstream	git@github.com:google/repo.git (push)

Step Three - Make Changes and keeping in sync

Workflow is :

  1. git fetch upstream to note changes on main repo
  2. git merge upstream/master to sync local repo to main repo
  3. git checkout -b new_branch to create a new branch to make a change
  4. Make changes on branch, commit etc as usual (make sure user.name and user.email is correct)
  5. Create a pull request through the web interface from main repo to merge changes from fork repo's branch to main repo's master
  6. Get +1 from someone else on main repo, make changes as needed locally
  7. Merge pull request
@credentiality
Copy link

Don't I need to 'git pull' or something somewhere in Step Three?

@credentiality
Copy link

I believe "git remote add upstream git@github.com:google/repo.git" should be "git remote add upstream git@github.com:google/prudaq.git"

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