0
0
Gitdevops~5 mins

Default branch name configuration in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the default branch name in Git when you create a new repository?
The default branch name is usually main in modern Git versions. Older versions used master.
Click to reveal answer
beginner
How can you check the current default branch name in your local Git repository?
You can run git branch --show-current to see the current branch you are on, or check remote default with git remote show origin.
Click to reveal answer
intermediate
How do you change the default branch name for new Git repositories globally?
Use the command git config --global init.defaultBranch <branch-name> to set the default branch name for all new repositories you create.
Click to reveal answer
intermediate
What command initializes a new Git repository with a custom default branch name?
Run git init --initial-branch=<branch-name> to create a new repo with a specific default branch name.
Click to reveal answer
beginner
Why might you want to change the default branch name from 'master' to 'main'?
Changing to main is a modern convention to use more inclusive language and is now the default in Git and many platforms.
Click to reveal answer
Which Git command sets the default branch name globally for new repositories?
Agit branch -m main
Bgit config --global init.defaultBranch main
Cgit checkout -b main
Dgit remote set-head origin main
What is the default branch name used by Git versions before 2.28?
Amaster
Bprimary
Cdefault
Dmain
How do you initialize a new Git repository with the default branch named 'develop'?
Agit init --initial-branch=develop
Bgit branch develop
Cgit checkout develop
Dgit config init.defaultBranch develop
Which command shows the current branch you are working on?
Agit remote show origin
Bgit status
Cgit branch --show-current
Dgit log
Why is 'main' preferred over 'master' as the default branch name?
ABecause 'main' is shorter
BBecause 'master' is deprecated in Git
CBecause 'main' is the only supported name now
DTo follow modern inclusive language practices
Explain how to change the default branch name for all new Git repositories on your computer.
Think about a global Git configuration command.
You got /3 concepts.
    Describe the difference between changing the default branch name for new repositories and renaming the branch in an existing repository.
    Consider commands for new repo setup vs branch rename.
    You got /3 concepts.