Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a Git alias?
A Git alias is a shortcut name for a longer Git command or series of commands. It helps you run common commands faster by typing a short word instead of the full command.
Click to reveal answer
beginner
How do you create a Git alias for the command git status?
You run git config --global alias.st status. Now, typing git st will show the status.
Click to reveal answer
intermediate
Where are Git aliases stored when created with --global?
They are stored in the global Git configuration file, usually located at ~/.gitconfig.
Click to reveal answer
intermediate
How can you list all Git aliases you have set?
Run git config --get-regexp alias to see all aliases and their commands.
Click to reveal answer
advanced
Can Git aliases include multiple commands or shell commands?
Yes, by prefixing the alias command with an exclamation mark !, you can run shell commands or multiple commands in one alias.
Click to reveal answer
Which command creates a Git alias named co for checkout?
Agit config alias.co checkout
Bgit alias co checkout
Cgit config --global alias.co checkout
Dgit alias --global co checkout
✗ Incorrect
The correct syntax is git config --global alias.co checkout to create a global alias.
After creating an alias st for status, how do you use it?
Agit st
Bgit status st
Cgit alias st
Dgit use st
✗ Incorrect
You simply run git st to use the alias for git status.
Where does Git store aliases created without the --global flag?
AIn the system-wide Git config file
BIn the user's home directory
CIn the Git installation folder
DIn the current repository's local Git config file
✗ Incorrect
Without --global, aliases are stored in the local Git config file inside the current repository.
How do you create a Git alias that runs a shell command?
Agit alias ls !ls -la
Bgit config alias.ls '!ls -la'
Cgit config alias.ls ls -la
Dgit alias ls ls -la
✗ Incorrect
Prefixing the command with ! tells Git to run it as a shell command.
What command lists all Git aliases you have set?
Agit config --get-regexp alias
Bgit config --list
Cgit alias list
Dgit alias --show
✗ Incorrect
Use git config --get-regexp alias to list all aliases.
Explain how to create and use a Git alias for a common command like git status.
Think about how to shorten commands you use often.
You got /3 concepts.
Describe how Git aliases can run shell commands and why that might be useful.
Consider how to extend Git commands beyond built-in ones.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of creating aliases in Git?
easy
A. To change the Git version
B. To delete branches automatically
C. To create new repositories
D. To make commands shorter and easier to type
Solution
Step 1: Understand what aliases do
Aliases are shortcuts that replace longer commands with shorter names.
Step 2: Identify the main benefit
Shorter commands save time and reduce typing effort.
Final Answer:
To make commands shorter and easier to type -> Option D
Quick Check:
Aliases = Shorter commands [OK]
Hint: Aliases shorten commands for faster typing [OK]
Common Mistakes:
Thinking aliases change Git versions
Confusing aliases with deleting branches
Believing aliases create repositories
2. Which of the following is the correct syntax to create a global alias named st for status in Git?
easy
A. git config alias.st status --global
B. git alias --global st status
C. git config --global alias.st status
D. git create alias st status
Solution
Step 1: Recall the alias creation syntax
The correct syntax is git config --global alias.name 'command'.
Step 2: Match the syntax to the options
git config --global alias.st status matches the correct syntax exactly.
Final Answer:
git config --global alias.st status -> Option C
Quick Check:
Correct syntax = git config --global alias.st status [OK]
Hint: Use 'git config --global alias.name command' format [OK]
Common Mistakes:
Placing --global after alias name
Using 'git alias' instead of 'git config'
Incorrect command order
3. Given the alias creation command git config --global alias.co checkout, what will be the output of git co?
medium
A. Runs the 'checkout' command
B. Throws an error: unknown command
C. Displays the commit history
D. Shows the current branch status
Solution
Step 1: Understand the alias mapping
The alias 'co' is set to run the 'checkout' command.
Step 2: Predict the effect of 'git co'
Typing 'git co' runs 'git checkout'.
Final Answer:
Runs the 'checkout' command -> Option A
Quick Check:
Alias 'co' = 'checkout' command [OK]
Hint: Alias runs the mapped command exactly [OK]
Common Mistakes:
Confusing 'co' with 'status'
Expecting output instead of command execution
Assuming alias causes error
4. You tried to create an alias with git config --global alias.br branch -a but typing git br gives an error. What is the most likely mistake?
medium
A. Alias command was not saved due to missing quotes
B. Alias was created locally, not globally
C. You need to restart Git to apply aliases
D. The alias name 'br' is reserved and cannot be used
Solution
Step 1: Check alias creation syntax
Quotes around the command are needed to save the alias properly.
Step 2: Identify the error cause
Missing or incorrect quotes cause the alias not to save, leading to errors when used.
Final Answer:
Alias command was not saved due to missing quotes -> Option A
Quick Check:
Missing quotes = alias not saved [OK]
Hint: Always quote the command when creating aliases [OK]
Common Mistakes:
Assuming alias applies without quotes
Thinking Git needs restart for aliases
Believing alias names are reserved
5. You want to create a Git alias named lg that shows a pretty log graph with one command. Which of these commands correctly creates this alias?
hard
A. git config alias.lg 'log --graph --oneline --all' --global
B. git config --global alias.lg "log --graph --oneline --all"
C. git alias --global lg 'log --graph --oneline --all'
D. git config --global alias.lg log --graph --oneline --all
Solution
Step 1: Recall correct alias syntax with multiple options
Use quotes to include all options as one command string.
Step 2: Identify the correct command format
git config --global alias.lg "log --graph --oneline --all" uses correct syntax with double quotes and global flag first.