Challenge - 5 Problems
Default Branch Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Check the current default branch name setting
What is the output of this command if the default branch name is set to 'main'?
Git
git config --global init.defaultBranchAttempts:
2 left
💡 Hint
The command shows the configured default branch name for new repositories.
✗ Incorrect
The command 'git config --global init.defaultBranch' outputs the name set as the default branch for new git repositories. If set to 'main', it outputs 'main'.
❓ Configuration
intermediate1:30remaining
Set the default branch name to 'develop'
Which command correctly sets the global default branch name to 'develop' for new git repositories?
Attempts:
2 left
💡 Hint
The correct syntax uses a space between the key and value without equals sign.
✗ Incorrect
The correct syntax to set a git config value is 'git config --global key value'. Using equals sign or quotes incorrectly causes errors or wrong settings.
❓ Troubleshoot
advanced2:00remaining
Why does 'git init' still create 'master' branch after setting defaultBranch?
You set the default branch name globally to 'main' using 'git config --global init.defaultBranch main'. But when you run 'git init' in a new folder, the branch is still named 'master'. What is the most likely reason?
Attempts:
2 left
💡 Hint
Check your git version supports this feature introduced recently.
✗ Incorrect
The init.defaultBranch setting was introduced in git 2.28. Older versions ignore this setting and default to 'master'.
🔀 Workflow
advanced2:30remaining
Change default branch name in an existing repository
You want to rename the default branch from 'master' to 'main' in an existing git repository. Which sequence of commands correctly achieves this?
Attempts:
2 left
💡 Hint
Rename branch locally, push new branch, delete old branch remotely, update HEAD reference.
✗ Incorrect
The correct workflow renames 'master' to 'main' locally, pushes 'main' branch, deletes 'master' branch remotely, and updates the remote HEAD to point to 'main'.
✅ Best Practice
expert3:00remaining
Best practice for setting default branch name in a team environment
In a team using git, what is the best practice to ensure all members use 'main' as the default branch name for new repositories?
Attempts:
2 left
💡 Hint
Centralized control and documentation help maintain consistency.
✗ Incorrect
Setting the default branch in the hosting service ensures all new repositories start with 'main'. It is more reliable than relying on individual local settings.