0
0
Gitdevops~20 mins

Default branch name configuration in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Default Branch Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1: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.defaultBranch
Amain
Bmaster
Cdefault
Dorigin
Attempts:
2 left
💡 Hint
The command shows the configured default branch name for new repositories.
Configuration
intermediate
1:30remaining
Set the default branch name to 'develop'
Which command correctly sets the global default branch name to 'develop' for new git repositories?
Agit config --global init.defaultBranch= 'develop'
Bgit config --global init.defaultBranch=develop
Cgit config --global init.defaultBranch 'develop'
Dgit config --global init.defaultBranch develop
Attempts:
2 left
💡 Hint
The correct syntax uses a space between the key and value without equals sign.
Troubleshoot
advanced
2: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?
AThe git version is older and does not support init.defaultBranch setting
BYou need to restart the terminal for the setting to apply
CThe repository already exists with master branch
DYou must set init.defaultBranch locally, not globally
Attempts:
2 left
💡 Hint
Check your git version supports this feature introduced recently.
🔀 Workflow
advanced
2: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?
A
git branch -m main master
git push origin master
git push origin --delete main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/master
B
git branch -m master main
git push origin main
git push origin --delete master
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
C
git branch -m master main
git push origin main
git push origin --delete main
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
D
git branch -m main master
git push origin main
git push origin --delete master
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
Attempts:
2 left
💡 Hint
Rename branch locally, push new branch, delete old branch remotely, update HEAD reference.
Best Practice
expert
3: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?
AAsk each member to run 'git config --global init.defaultBranch main' on their machines
BCreate a script that runs 'git init -b main' and share it with the team
CSet the default branch name in the central repository hosting service settings (e.g., GitHub) and document it
DIgnore default branch naming and rename branches manually after creation
Attempts:
2 left
💡 Hint
Centralized control and documentation help maintain consistency.