Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to shorten branch names in git commands?

Tags:

git

git-branch

When I work on a bigger project, I use long branch names, eg. dev/username/PROJECT-JIRANUM_some_description. It would be cool to be able to do sth like this:

git branch -D STH(xxxx)

Where STH() is some syntax that would use some glob-like matching of branch names (so that xxxx could be a JIRA number contained in branch name). If there is ambiguity, git would inform and abort the command.

It sth like this is possible at the moment? I could not find any information on this.

like image 300
tkleczek Avatar asked Sep 08 '25 19:09

tkleczek


1 Answers

I would recommend using zsh with prezto since it gives you branch name completion as follows: ('...' appears every time I press tab for branch name completion)

enter image description here

If you go down this route, for reference here is the list of prezto modules I've enabled (in ~/.zpreztorc):

# Set the Prezto modules to load (browse modules).
# The order matters.
zstyle ':prezto:load' pmodule \
  'environment' \
  'terminal' \
  'editor' \
  'history' \
  'archive' \
  'directory' \
  'spectrum' \
  'utility' \
  'completion' \
  'ssh' \
  'git' \
  'history-substring-search' \
  'prompt'

I believe the important ones (for what you need) are utility, completion and git

like image 73
Ashutosh Jindal Avatar answered Sep 10 '25 09:09

Ashutosh Jindal