Last active
September 24, 2020 14:39
-
-
Save the-glima/5912b8c98bef97c19bc4c0ca3b4e29ee to your computer and use it in GitHub Desktop.
[Git] Sync your current branch with another #website
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
# Add this to your .bash-aliases | |
function syncBranch() { | |
# Get your current branch | |
local CURRENT_BRANCH=$(git symbolic-ref --short HEAD) | |
local CURRENT_BRANCH="${CURRENT_BRANCH}" | |
# If you don't pass any argument it will use the default branch | |
local BASE_BRANCH="${1:-master}" | |
# Customize this command as fits you, i.e.: not using --no-ff, using rebase or passing dynamic args, etc... | |
git checkout "${BASE_BRANCH}" && git pull -p && git checkout "${CURRENT_BRANCH}" && git merge "${BASE_BRANCH}" --no-ff | |
} | |
# How to use | |
# $ syncBranch | |
# $ syncBranch branch-name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment