-
-
Save fengshuo/b0fe2721cbc0f6cae2ac380c4596cb8f to your computer and use it in GitHub Desktop.
Copy current git branch to clipboard
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
For those, who don't know how to make this work: create a file, e.g. git_branch_name_to_clipboard.sh in your user directory with following content: | |
`git branch | grep "*" | awk '{ print $2 }' | pbcopy` | |
or use this to remove the new line when you paste: | |
`git branch | grep "*" | awk '{ print $2 }' | tr -d '\n' | pbcopy` | |
Then in `.gitconfig file`, which is located in your user folder, add these lines under [alias]: | |
`cp = "!sh $HOME/git_branch_name_to_clipboard.sh"` | |
Now performing git cp will copy your current branch name to clipboard. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment