Skip to content

Instantly share code, notes, and snippets.

@neikeq
Last active August 29, 2015 14:17
Show Gist options
  • Save neikeq/8c81fb4192cec759782e to your computer and use it in GitHub Desktop.
Save neikeq/8c81fb4192cec759782e to your computer and use it in GitHub Desktop.
Synchronize the forked repo without removing the local changes nor pushing them to origin. This code assumes that the local changes are in the private-changes branch and that master does not have changes to commit.
:: git remote add neikeq https://github.com/neikeq/KicksEmu.git
:: Create a branch for our local changes if it does not exists
git checkout -b private-changes
:: Fetch the updates from neikeq
git fetch neikeq
:: Commit all the changes from private-changes branch and merge updates
git checkout private-changes
git add -u .
git status
git commit -m "Local changes..."
git merge neikeq/master
:: Merge updates to master and push it to the github forked repo
git checkout master
:: git reset --hard HEAD
git merge neikeq/master
git push -u origin master
:: Back to the branch with the local changes
git checkout private-changes
PAUSE
#!/bin/bash
# git remote add upstream https://github.com/neikeq/KicksEmu.git
# Create a branch for our local changes if it does not exists
git checkout -b private-changes
# Fetch the updates from upstream
git fetch upstream
# Commit all the changes from private-changes branch and merge upstream
git checkout private-changes
git add -u .
git status
git commit -m "Local changes..."
git merge upstream/master
# Merge upstream to master and push it to the github forked repo
git checkout master
# git reset --hard HEAD
git merge upstream/master
git push -u origin master
# Back to the branch with the local changes
git checkout private-changes
read -n1 -r -p "Press any key to continue..." key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment