... | ... | @@ -495,6 +495,29 @@ GitLab API, that is: |
|
|
3. change the default branch
|
|
|
4. *then* `git push -d` to delete the old 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
|
|
|
changes. You will then need to provide an [access token](https://gitlab.torproject.org/-/profile/personal_access_tokens) through
|
|
|
the `GITLAB_PRIVATE_TOKEN` environment variable. So, for example, this
|
|
|
will rename the `master` branch to `main` on the local and remote
|
|
|
repos:
|
|
|
|
|
|
GITLAB_PRIVATE_TOKEN=REDACTED git-branch-rename-remote
|
|
|
|
|
|
If you want to rename another branch or remote, you can specify those
|
|
|
on the commandline as well. For example, this will rename the
|
|
|
`develop` branch to `dev` on the `gitlab` remote:
|
|
|
|
|
|
GITLAB_PRIVATE_TOKEN=REDACTED git-branch-rename-remote --remote gitlab --from-branch develop --to-branch dev
|
|
|
|
|
|
The command can also be used to fix *other* repositories so that they
|
|
|
correctly rename their local branch too. In that case, the GitLab
|
|
|
repository is already up to date, so there is no need for an access
|
|
|
token, and just running this command will rename `master` to `main` on
|
|
|
the local repo, including remote tracking branches:
|
|
|
|
|
|
git-branch-rename-remote
|
|
|
|
|
|
However, there are a few extra steps and considerations to make when
|
|
|
changing the name of a heavily used branch.
|
|
|
|
... | ... | |