Script for renaming branches in both remote and local git repositories simultaneously
AI Translation
This post is translated from Japanese into English through AI.View Original
AI-generated summary
To rename a local Git branch and update the remote:
1. Rename the local branch:
```bash
git branch -m $old_name $new_name
```
2. Delete the old branch from the remote:
```bash
git push $remote --delete $old_name
```
or:
```bash
git push $remote :$old_name
```
3. Unset the upstream for the new branch to avoid using the old name:
```bash
git branch --unset-upstream $new_name
```
4. Push the new branch to the remote:
```bash
git push $remote $new_name
```
5. Set the upstream for the new branch:
```bash
git push $remote -u $new_name
```