Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

gitlab - How to rename git remote branch name from upper case to lower case same name?

I have a git branch named QA, I want to rename it to lower case qa because I use the repository in gitlab pipeline and in gitlab pipeline the branch names are case sensitive.

I tried this post to rename the branch https://linuxize.com/post/how-to-rename-local-and-remote-git-branch/

It works when the new and old branch names are different but does not when we try to change the letters' casing.

So I am now stuck with this name.

Any idea if that is even achievable or not and how?

question from:https://stackoverflow.com/questions/65832299/how-to-rename-git-remote-branch-name-from-upper-case-to-lower-case-same-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you have this issue I suppose you use a case insensitive file system locally (branches are stored as files in .git directory) that means that git checkout QA and git checkout qa brings you to the same branch, even if you never created the qa branch.

You can also check it with git branch that list you only QA and not qa, but git checkout qa works and brings you to the same commit pointed out by QA (check with git log also).

That said you can't rename QA to qa locally because for git is the same branch and will say you A branch named 'qa' already exists..

A solution could be create a backup branch, delete the original and rename the backup with the right name. Than push on the remote.

git branch qa_backup QA
git branch -d QA
git branch -m qa_backup qa
git push -u origin qa

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...