Macro#

Create#

Add the following to your ~/.gitconfig.

bpc = "!f() { git branch ${1} && git push --set-upstream origin ${1} && git checkout ${1}; }; f"

Run as

git bpc myBranch

This will create the local branch, push it, and check it out.

Delete#

Add the following to your ~/.gitconfig.

bdf = "!f() { git branch -D ${1} && git push origin --delete ${1}; }; f"

Run as

git bdf myBranch

from any branch other than byBranch.

This will delete both local and remote copies of the branch.

Manual#

Locally, to create and checkout the branch do -

$ git checkout -b your_branch

Then, to push your branch to origin, do -

$ git push -u origin your_branch

Git