Last active
January 20, 2025 17:31
-
-
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 |
As of Git 2.22 just:
git branch --show-current | pbcopy
This is very useful
Thanks @Pezmc 🙏
thanks
thanks sir!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks