Last active
October 28, 2022 20:31
-
-
Save matthewadowns/32a549719816ab3a52f0c997ba7804c4 to your computer and use it in GitHub Desktop.
Quickly push a new branch upstream when checking out a new branch with this shell function and alias
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
# Add this to your shell profile (e.g. .zshrc or .bashrc) | |
publishBranch() { | |
git checkout -b $1 | |
git push -u origin $1 | |
} | |
alias gcb=publishBranch | |
######################### | |
# Usage | |
# > gcb my-new-branch | |
# Branch 'my-new-branch' set up to track local branch 'master' by rebasing. | |
# Switched to a new branch 'my-new-branchh' | |
# Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 | |
# remote: | |
# remote: Create a pull request for 'my-new-branch' on GitHub by visiting: | |
# remote: https://github.com/YOURORG/SOMEREPO/pull/new/my-new-branch | |
# remote: | |
# To github.com:YOURORG/SOMEREPO.git | |
# * [new branch] my-new-branch -> my-new-branch | |
# Branch 'my-new-branch' set up to track remote branch 'my-new-branch' from 'origin' by rebasing. | |
######################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment