Skip to content

Instantly share code, notes, and snippets.

@sheenobu
Created October 31, 2012 19:49
Show Gist options
  • Save sheenobu/3989374 to your computer and use it in GitHub Desktop.
Save sheenobu/3989374 to your computer and use it in GitHub Desktop.
Merging of remote code while keeping local modifications and avoiding weird merges
#!/bin/bash
# An assumption is that our stash stack is already empty, otherwise a
# git stash && git stash pop
# would pop stacks even if git stash failed to save anything.
# (git stash could return a non-zero on 'no stash created' BUT it doesn't (yet) )
# store local changes
git stash
# fetch the upstream changes
git fetch origin
# reset the entire git repo
git reset --hard origin
# check out your branch
git checkout
# pull remote (we could probably just git merge <branchname>)
git pull
# pull out local changes
git stash pop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment