Skip to content

Instantly share code, notes, and snippets.

@gilesbowkett
Created May 1, 2013 20:54
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 gilesbowkett/5498308 to your computer and use it in GitHub Desktop.
Save gilesbowkett/5498308 to your computer and use it in GitHub Desktop.
github help article implemented as shell script. is there an easier way?
# based on the workflow from https://help.github.com/articles/syncing-a-fork
function fetch_remotes() {
for remote in $(echo $(git remote))
do
git fetch $remote
done
}
function hub_sync() {
git co master &&
fetch_remotes &&
git merge upstream/master &&
git push origin master &&
git st
}
hub_sync
@gilesbowkett
Copy link
Author

where st is an alias for status, and co for checkout

@gilesbowkett
Copy link
Author

and based on the assumption that you want to keep track of a lot of different stuff your team is doing

@jasonkarns
Copy link

fetch_remotes could be replaced with git fetch --all, IIRC

@jasonkarns
Copy link

I would also recommend using either git rebase upstream/master instead of git merge or adding the --ff-only flag to the merge command. This way your fork's history closely matches the upstream. Otherwise your fork could begin to accumulate merge-commits.

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