DEV Community

Cover image for Copy the name of your current branch
Domenik Reitzner
Domenik Reitzner

Posted on

Copy the name of your current branch

I just wanted to share a quick helper that I have been using for a while.

History

One of the projects I work at has some nicely set up development servers (different variations of cms and business api).

So whenever we need to test a specific configuration on a feature that we are developing, we will put that branch on one of the development servers. For that to happen we need to adapt the configuration inside of the build server and change the branch name.

So after multiple times of changing the branch name, waiting for the build to finish, testing on the server, not seeing my changes and finding out, that I had a typo in the name, I decided I'd hunt for a better solution.

The easy fix I've used ever since.

This is the easy solution I found:

// windows
git branch --show-current | clip
Enter fullscreen mode Exit fullscreen mode
// macOS
git branch --show-current | pbcopy
Enter fullscreen mode Exit fullscreen mode

I hope ths makes your live easier and you can focus more of your time on the things you love to do.

Credits

cover: https://unsplash.com/@yancymin

Top comments (0)