Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change my local Git branch name to uppercase

I created a branch from my master (origin) and called it TEST-101 (uppercase). I then worked on my branch and committed and pushed my changes up to origin. When I log in to Github, I can see I the branch I created.

I used git bash and checked out my local version of the branch, but I entered it in all lowercase: test-101. I then used Git Gui and committed my changes to the branch which was typed in lower case, and when I tried to push these changes it gave me an error:

POST git-receive-pack (390618 bytes)
remote: error: failed to lock refs/heads/test-101
Pushing to ht://example/example/example/example.git
To ht://example/example/example/example.git
! [remote rejected] test-101 -> test-101 (failed to lock)
error: failed to push some refs to 'http://example/example/example/example.git'

(Please note that I have changed some private info in the error.)

I have done some reading, and it appears that my local branch being in lowercase and the remote branch being in uppercase may be causing an issue?

like image 613
Paul Avatar asked Dec 14 '22 18:12

Paul


2 Answers

The following solved the problem:

git branch -m test-101 tmp_branch
git branch -m tmp_branch TEST-101
like image 105
Paul Avatar answered Dec 26 '22 16:12

Paul


You can do the following:

git branch -m test-101 tmp_branch
git checkout tmp_branch
git merge TEST-101 // make sure your data is up to date
git branch -D TEST-101
git branch -m tmp_branch TEST-101

-m option renames the branch, and -D option will delete the branch.

like image 22
Surya Avatar answered Dec 26 '22 17:12

Surya