Skip to content

Instantly share code, notes, and snippets.

@the-glima
Last active September 24, 2020 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-glima/5912b8c98bef97c19bc4c0ca3b4e29ee to your computer and use it in GitHub Desktop.
Save the-glima/5912b8c98bef97c19bc4c0ca3b4e29ee to your computer and use it in GitHub Desktop.
[Git] Sync your current branch with another #website
# 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