From accbea7a031b5d1e47dc59a23db9ed491abcad55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@debian.org> Date: Tue, 18 May 2021 14:06:56 -0400 Subject: [PATCH] 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. --- howto/gitlab.md | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/howto/gitlab.md b/howto/gitlab.md index d30a4d63..70620a43 100644 --- a/howto/gitlab.md +++ b/howto/gitlab.md @@ -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 -- GitLab