mirror of
https://github.com/jbranchaud/til
synced 2026-01-05 16:18:01 +00:00
Add Set Default Branch Name For New Repos as a git TIL
This commit is contained in:
22
git/set-default-branch-name-for-new-repos.md
Normal file
22
git/set-default-branch-name-for-new-repos.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Set Default Branch Name For New Repos
|
||||
|
||||
When you run `git init` in a directory, it will initialize that directory as a
|
||||
`git` repository. The default branch name for any new git repository is
|
||||
`master`. A better name for the base branch would be something like `main`.
|
||||
|
||||
To set `main` as the new default for all new repos, you can run the following
|
||||
`git` command.
|
||||
|
||||
```bash
|
||||
$ git config --global init.defaultBranch main
|
||||
```
|
||||
|
||||
This will update your `.gitconfig` file to contain the following lines.
|
||||
|
||||
```
|
||||
[init]
|
||||
defaultBranch = main
|
||||
```
|
||||
|
||||
Try running `git init` in a fresh directory and then `git branch
|
||||
--show-current` to see that the base branch is now defaulting to `main`.
|
||||
Reference in New Issue
Block a user