Created
October 31, 2012 19:49
-
-
Save sheenobu/3989374 to your computer and use it in GitHub Desktop.
Merging of remote code while keeping local modifications and avoiding weird merges
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
#!/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