Last active
August 29, 2015 14:26
-
-
Save Fweeb/7f2f8c420f067647d3a1 to your computer and use it in GitHub Desktop.
Steps to fork a github project
This file contains 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
# THIS IS NOT MEANT TO BE A SCRIPT YOU ACTUALLY RUN. | |
#################################################### | |
# Use these steps to work on a project fork on GitHub and create your own dev branch | |
# (this assumes that you've already created a fork through GitHub's interface) | |
cd ~/src # or where ever you keep your source code | |
git clone https://github.com/YourUser/project.git # Where "YourUser" is your username and "project" is your forked project | |
cd project | |
# Track the upstream project you forked from | |
git remote add --track master upstream git://github.com/ForkedUser/project.git # Where "ForkedUser" is the upstream owner | |
git fetch upstream | |
git merge upstream/master # Should already be up to date | |
# Make your branch and switch to it | |
git branch mybranch | |
git checkout mybranch | |
# Make code changes with whatever tools you can. Let's assume you already have a patch with changes to apply: | |
patch -p1 < mychanges.patch | |
# Commit your changes to your branch | |
git commit -a -m "I made changes. If this were a real comment, I'd be more specific." | |
# Push your changes back to your fork on GitHub (including the new branch) | |
git push --set-upstream origin mybranch | |
# For safety's sake, you may want to make a diff file of your changes (it may help syncing in the future) | |
git diff master mybranch > mychanges.patch | |
################# | |
# Flash forward to the future when changes have been made upstream. You want to sync your branch with upstream | |
git checkout master | |
git fetch upstream | |
git merge upstream/master | |
# You should probably do a commit after this to commit the merged changes from upstream | |
git commit -a -m "Merged changes from upstream master" | |
# Now pull those changes into your branch as per: http://stackoverflow.com/questions/16955980/git-merge-master-into-feature-branch | |
git checkout mybranch | |
git rebase master # This will require manually managing conflicts | |
git rebase --skip | |
# Now commit your merged changes | |
git commit -a -m "Merged changes from master" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment