Last active
August 24, 2017 20:24
-
-
Save nofuturekid/8511f9158cf2346fc8bd64241d524f7d to your computer and use it in GitHub Desktop.
Syncing fork with upstream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Foreword: Your fork is the "origin" and the repository you forked from is the "upstream". | |
| # Let's assume that you cloned already your fork to your computer with a command like this: | |
| # | |
| git clone git@github.com:your_name/project_name.git | |
| cd project_name | |
| # If that is given then you need to continue in this order: | |
| # | |
| # Add the "upstream" to your cloned repository ("origin"): | |
| # | |
| git remote add upstream git@github.com:original_author/project_name.git | |
| # Fetch the commits (and branches) from the "upstream": | |
| # | |
| git fetch upstream | |
| # Switch to the "master" branch of your fork ("origin"): | |
| # | |
| git checkout master | |
| # Stash the changes of your "master" branch: | |
| # | |
| git stash | |
| # Merge the changes from the "master" branch of the "upstream" into your the "master" branch of your "origin": | |
| # | |
| git merge upstream/master | |
| # Resolve merge conflicts if any and commit your merge | |
| # | |
| git commit -am "Merged from upstream" | |
| # Push the changes to your fork | |
| # | |
| git push | |
| # Get back your stashed changes (if any) | |
| # | |
| git stash pop | |
| # You're done! Congratulations! |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GitHub also provides instructions for this topic:
Syncing a fork (https://help.github.com/articles/syncing-a-fork)