Bird
0
0

You created an alias with git config alias.lg 'log --oneline' but git lg gives an error. Why?

medium📝 Troubleshoot Q7 of 15
Git - Configuration and Aliases
You created an alias with git config alias.lg 'log --oneline' but git lg gives an error. Why?
AAlias names cannot contain two letters
BAlias was created locally but you are in a different repository
CYou must restart Git to apply aliases
DThe command 'log --oneline' is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Understand alias scope

    Without --global, alias is local to the current repository only.
  2. Step 2: Check usage context

    If you run 'git lg' in a different repo, the alias won't exist, causing error.
  3. Final Answer:

    Alias was created locally but you are in a different repository -> Option B
  4. Quick Check:

    Local alias works only in current repo [OK]
Quick Trick: Local aliases apply only in the repo where created [OK]
Common Mistakes:
  • Assuming aliases are global by default
  • Thinking Git needs restart for aliases
  • Believing 'log --oneline' is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes