0
0
Gitdevops~20 mins

Creating aliases for common commands in Git - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Alias Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of a Git alias command
What is the output of running git co after setting the alias co to checkout?
Git
git config --global alias.co checkout
git co -b new-branch
ALists all branches in the repository.
BShows an error: 'git: 'co' is not a git command.'
CDeletes the branch named 'new-branch'.
DCreates and switches to a new branch named 'new-branch'.
Attempts:
2 left
💡 Hint
Think about what 'checkout -b' does in Git.
Configuration
intermediate
1:30remaining
Correct syntax for setting a Git alias
Which command correctly sets a Git alias named st for status?
Agit config --global alias.st status
Bgit alias set st status
Cgit config alias.st=status
Dgit set alias st status
Attempts:
2 left
💡 Hint
Git aliases are set using the config command with 'alias.' prefix.
Troubleshoot
advanced
2:00remaining
Troubleshooting a Git alias that does not work
You set a Git alias lg as log --oneline --graph but running git lg gives an error. What is the most likely cause?
Git
git config --global alias.lg 'log --oneline --graph'
AThe alias command must be set without quotes around the value.
BThe alias should not include spaces; use a shell script instead.
CThe alias is correct; the error is due to missing Git repository.
DThe alias command needs double quotes instead of single quotes.
Attempts:
2 left
💡 Hint
Check how Git stores alias commands in the config file.
🔀 Workflow
advanced
2:30remaining
Using Git aliases in a workflow
You have these aliases set:
git config --global alias.co checkout
git config --global alias.br branch
Which sequence of commands uses these aliases to create and switch to a new branch named feature and then list all branches?
Agit checkout feature && git branch -a
Bgit co -b feature && git br
Cgit br -b feature && git co
Dgit br feature && git co -a
Attempts:
2 left
💡 Hint
Remember what 'checkout -b' and 'branch' commands do.
Best Practice
expert
2:00remaining
Best practice for naming Git aliases
Which of the following is the best practice when naming Git aliases for common commands?
AUse names that match existing Git commands to override them for customization.
BUse long descriptive names to avoid confusion, even if they are hard to type.
CUse short, memorable names that do not conflict with existing Git commands.
DUse random letters to ensure uniqueness, regardless of readability.
Attempts:
2 left
💡 Hint
Think about ease of use and avoiding errors.