Created
April 23, 2024 04:50
-
-
Save adityadaniel/372adba4d5aee3f817fb1f1870c98eff to your computer and use it in GitHub Desktop.
Sync current feature branch with latest changes from base branch
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
#!/bin/bash | |
function sync_base() { | |
parent=$(git show-branch | grep '*' | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//') | |
current=$(git rev-parse --abbrev-ref HEAD) | |
echo "base $parent, current: $current" | |
echo "Switching to parent: $parent, make sure you already commit all your work" | |
git checkout $parent && git pull | |
echo "Switching to your current branch: $current" | |
git checkout $current | |
git merge $parent | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment