Skip to content

Instantly share code, notes, and snippets.

@vcavallo
Last active December 24, 2015 00:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vcavallo/6715212 to your computer and use it in GitHub Desktop.
Save vcavallo/6715212 to your computer and use it in GitHub Desktop.
Forking how-to with descriptions

Forking

essentially like cloning on github's servers - but that's inconsequential, mostly.. also: forks are not automatically up to date (relative to repo you forked)! your fork creates a snapshot of the original repo at the time you fork it.

  • fork on github

  • creates a clone on github servers

  • copy url of that clone

  • git clone [url]

    • clones the content of your fork to your local machine
  • git remote add upstream git@github.com:flatiron-school/003-ruby-lectures [or whatever the repo url is]

    • adds remote repo to your local
  • git fetch upstream

    • adds new changes from original repo to your local machine.
  • git merge upstream/master

    • (while in local master, assuming there have been changes on the original)
  • git push origin master

    • pushes to your github fork, not original repo
  • submit pull request to original repo when you'd like to attempt to get your work integrated into original repo

Bonus! Viewing differences

using diff to comapre changes between local and upstream:

  • git diff upstream/master master | subl
    • where upstream/master is the remote (original), master is your local master branch and | subl sends the result to a sublime file instead of to the terminal output.
    • reverse the order of upstream master and master to see the diff from the "opposite point of view", so to speak. Meaning, adds will look like removes and vice-versa [I haven't yet figured out the better way to approach this]
    • this git diff can also be used with your own remote repo (origin/master vs upstream/master)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment