User Tools

Site Tools


rename_branch

Try to disable the branch protection in the settings/repository page. Check the sections Default Branch and Protected Branches

After that:

Checkout the branch locally.

git checkout branch

Rename it locally

git checkout -b branch_old

delete remote branch

git push --delete origin branch

push the locally renamed branch to remote.

git push --set-upstream origin branch_old

How do I delete a local branch in Git?

Git makes managing branches really easy - and deleting local branches is no exception:

git branch -d <local-branch>

In some cases, Git might refuse to delete your local branch: when it contains commits that haven't been merged into any other local branches or pushed to a remote repository. This is a very sensible rule that protects you from inadvertently losing commit data.

If you want to delete such a branch nonetheless (e.g. because you've programmed yourself into a dead end and produced commits that aren't worth keeping) you can do so with the “-D” flag:

git branch -D <local-branch>
rename_branch.txt · Last modified: 2023/09/14 06:06 by 127.0.0.1