Skip to content

Instantly share code, notes, and snippets.

@naXa777
Last active November 2, 2018 11:22
Show Gist options
  • Save naXa777/349f9ff1b2cebfcf87a31966d7b28dd9 to your computer and use it in GitHub Desktop.
Save naXa777/349f9ff1b2cebfcf87a31966d7b28dd9 to your computer and use it in GitHub Desktop.
Git Sync Fork - a shell script for syncing a fork of a repository to keep it up-to-date with the upstream repository
#!/bin/bash
#
# Before you can run this script, you must configure a remote that points to the upstream repository in Git.
# example from .git/config:
# ```
# [remote "origin"]
# url = git@github.com:naXa777/tutorials.git
# fetch = +refs/heads/*:refs/remotes/origin/*
# [remote "upstream"]
# url = https://github.com/eugenp/tutorials
# fetch = +refs/heads/*:refs/remotes/upstream/*
# ```
#
# Help articles:
#
# - https://help.github.com/articles/syncing-a-fork/
# - https://help.github.com/articles/configuring-a-remote-for-a-fork/
pwd
git fetch upstream
git checkout master
git merge upstream/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment