Is it possible to rename an entire “directory of branches”?

29 views Asked by At

Git branches can have path-like names, such as f2003-conv/f90ppr-tool/debug_issueX. Is it possible to actually use these as directories, as in, rename f2003-conv/f90ppr-tool with all its sub-branches?

1

There are 1 answers

0
Kristján On

Since branch names are arbitrary, I don't think Git has any built-in way to do this, but here's a little script, credit to edenwaith.

git branch \
| grep f2003-conv/f90ppr-tool \
| awk '{original=$1; sub("f2003-conv/f90ppr-tool","simpler-path"); print original, $1}' \
| xargs -n 2 git branch -m