Last active
May 28, 2024 16:43
-
-
Save andrewmriley/6401eef48859519f483c to your computer and use it in GitHub Desktop.
Copy your current git branch name to clipboard
This file contains 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
## Choose one and add it as an alias or throw it in a script ## | |
### Modern Git Thanks to @Pezmc | |
# Linux/Unix Wayland | |
git branch --show-current | wl-copy | |
# Linux/Unix X11 | |
git branch --show-current | xclip -selection clipboard | |
# MacOS | |
git branch --show-current | pbcopy | |
### Pre Git 2.22 | |
# linux/unix | |
git rev-parse --abbrev-ref HEAD | tr -d '\n' | xclip -selection clipboard | |
# os x | |
git rev-parse --abbrev-ref HEAD | tr -d '\n' | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks