no-masters.md(文件已创建)
| @@ -0,0 +1,25 @@ | |||
| 1 | + | # Make Git always use `main` as default branch | |
| 2 | + | ||
| 3 | + | ## Git 2.28.0 | |
| 4 | + | ||
| 5 | + | ```sh | |
| 6 | + | git config --global init.defaultBranch main | |
| 7 | + | ``` | |
| 8 | + | ||
| 9 | + | ||
| 10 | + | ## Pre-Git 2.28.0 | |
| 11 | + | ||
| 12 | + | ```sh | |
| 13 | + | mkdir -p ~/.config/git/templates/default | |
| 14 | + | echo "ref: refs/heads/main" > ~/.config/git/templates/default/HEAD | |
| 15 | + | git config --global init.templateDir '~/.config/git/templates/default' | |
| 16 | + | ``` | |
| 17 | + | ||
| 18 | + | ||
| 19 | + | ## Make main your main | |
| 20 | + | ||
| 21 | + | `git branch -m master main && git push -u origin main` | |
| 22 | + | ||
| 23 | + | Next, tell GitHub or whoever your new default is `main`. Then you can tell the remote repo to destroy the old branch: | |
| 24 | + | ||
| 25 | + | `git push origin :master` | |
上一页
下一页