Skip to content
Snippets Groups Projects
Verified Commit accbea7a authored by anarcat's avatar anarcat
Browse files

remove shell pseudocode for branch rename

The rationale here is that's already available at the head of the
Python script, and was actually not directly tested recently. I only
put this together from memory (well, git history and guesses) so it
might actually not work at all. It's mostly pseudo-code, and shouldn't
be ran directly.

Instead, explain generally, with words, what the script does.
parent 56b18cb9
No related branches found
No related tags found
No related merge requests found
......@@ -469,31 +469,9 @@ branch. That process is more involved.
Changing the name of a default branch both locally and on remotes can
be partially automated with the use of [anarcat's branch rename
script](https://gitlab.com/anarcat/scripts/-/blob/main/git-branch-rename-remote). This script performs the following tasks:
```
# rename the branch locally if not already done
git show-ref refs/heads/master > /dev/null && \
git branch --move master main
git fetch origin
# fix HEAD pointer for local remote branch
git symbolic-ref refs/remotes/remote/HEAD refs/remotes/remote/main
# push branch remotely if it doesn't exist (or fix tracking branch if it does)
git branch -u origin/main || exit
git push -u origin main
# fix remote HEAD pointer on remote repository
ssh example.com git symbolic-ref HEAD main
# delete old branch
git push -d origin master
```
If the `ssh` step fails, it will try to do the equivalent over the
GitLab API, that is:
1. unprotect the old branch
2. protect the new branch
3. change the default branch
4. *then* `git push -d` to delete the old branch
script](https://gitlab.com/anarcat/scripts/-/blob/main/git-branch-rename-remote). The script basically renames the branch locally, pushes
the new branch and deletes the old one, with special handling of
GitLab remotes, where it "un-protects" and "re-protects" the branch.
You should run the script with an account that has "Maintainer" or
"Owner" access to GitLab, so that it can do the above GitLab API
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment