Skip to content

Instantly share code, notes, and snippets.

@mosheeshel
Last active November 1, 2021 14:15
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 mosheeshel/622f295b60338adc9264f43785e4de47 to your computer and use it in GitHub Desktop.
Save mosheeshel/622f295b60338adc9264f43785e4de47 to your computer and use it in GitHub Desktop.
Small script to improve git branch creation flow for users
create_branch() {
local ORIGIN_BRANCH="origin/main"
if [ -z "$1" ] ; then
echo "branch name is required"
else
if [ ! -z "$2" ] ; then
local ORIGIN_BRANCH="$2"
fi
git checkout -b $1 $ORIGIN_BRANCH
git push -u origin $1:$1
fi
}
alias branch=create_branch
@mosheeshel
Copy link
Author

Requires: Git SCM CLI, Bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment