-
-
Save upkarlidder/130f3f43fc19e8098bc0fc490082ebe9 to your computer and use it in GitHub Desktop.
When the user has changed into a git directory, rebase with upstream if there are no uncommitted files.
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
function cd { | |
# Run the system CD command on the parameters that were passed in | |
builtin cd "$@" | |
# Check if the directory we are in now is a git directory | |
if [ -d ".git" ]; then | |
# If so, check to see that there are no uncommitted files | |
if [ $(git status --porcelain 2>/dev/null| egrep "^(M| M)" | wc -l) ]; then | |
# Rebase our current branch with upstream/master | |
git fetch upstream && git rebase upstream/master | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment