Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.4k points)
edited by

I have four branches like master -> origin/regacy, FeatureA -> origin/FeatureA. As you can see, I typed the wrong name.

So I want to rename a remote branch name (origin/regacy → origin/legacy or origin/master)

I try the command below:

git remote rename regacy legacy

But Git console returned an error message to me.

 error : Could not rename config section 'remote.regacy' to 'remote.legacy'

How can I solve this problem?

1 Answer

0 votes
by (119k points)
edited by

At first, rename the local branch, then the remote branch.

Renaming the local branch:

If logged in another branch,

git branch -m old_branch new_branch 

If logged in the same branch,

git branch -m new_branch

Renaming remote branch:

git push origin: old_branch   

git push --set-upstream origin new_branch  

Also, check out this Git Tutorial to know more.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...