Created
March 15, 2022 13:04
-
-
Save yhauxell/2a9d677aa2e47edebb59da6e5862f970 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 gitsync(){ | |
CURRENT=$(git branch --show-current) | |
if [ -n "$1" ] | |
then | |
echo "Fetching branch $1" | |
git fetch origin $1:$1 | |
echo "Merging $1 into $CURRENT" | |
git merge $1 -m "Merged branch $1 into $CURRENT" | |
echo "Pushing changes" | |
git push | |
git checkout $CURRENT | |
else | |
echo "Missing branch name to sync from" | |
fi | |
} | |
alias sync=gitsync |
Then from the terminal in any part of a git project directory type for example to sync master branch: sync master
You can use rebase
at line 10 if wanted to as well, depends on your strategy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: add the function and alias to :
.bash_profile
or.zshrc