DevOps · Infrastructure as Code (IaC) · Git Series – Part 10
Even experienced developers and DevOps engineers don’t remember every Git command — and they don’t need to. Git provides excellent built-in help, documentation, examples, and command explainers right inside the CLI.
In this chapter, you’ll learn how to:
- Get help for any Git command
- View full documentation (man pages)
- Use built-in examples
- Explore subcommands deeply
- Find config options and advanced flags
- Discover commands you didn’t know existed
- Diagnose errors and understand Git output
This chapter makes you fully self-sufficient in using Git.
Table of Contents
1. Git Help Basics
The primary help command:
git help
This shows general usage and available commands grouped by purpose:
- Main commands
- Ancillary commands
- Internal commands
- Guides (aka “Concept Guides”)
2. Get Help for Any Command
The 3 ways to ask Git for help:
1. Using git help <command>
git help commit
git help log
git help merge
Opens the man page or HTML help (depending on your system).
2. Using manual pages directly
man git-commit
man git-log
3. Using --help
git commit --help
git branch --help
All three methods show the same content.
3. Short Usage Summary
Instead of full documentation:
git commit -h
git pull -h
git push -h
git checkout -h
This prints a quick, concise usage guide — extremely handy.
4. Explore Command Examples (Built-In!)
Many Git commands include practical examples at the end of their help pages.
Scroll to the bottom and look for:
EXAMPLES
For example:
git help log
Scroll down → you’ll see dozens of useful log examples.
These examples cover:
- filtering commits
- showing graphs
- formatting messages
- searching history
- limiting output
This is one of Git’s strongest built-in features.
5. Git Guides (Must-Read Built-In Documentation)
Git includes excellent conceptual guides:
git help glossary
git help revisions
git help everyday
git help workflows
git help tutorial
git help tutorial-2
git help worktree
Recommended for DevOps Engineers:
- git help revisions → explains commit ranges, hashes,
HEAD~1,HEAD^,branch1..branch2, etc. - git help glossary → every Git term explained
- git help workflows → team workflows
- git help everyday → practical commands for daily use
- git help worktree → using multiple worktrees (amazing for IaC work)
6. Explore Available Commands
List all Git commands:
git help -a
Shows:
- porcelain commands
- plumbing commands
- experimental commands
- internal tools
List guides and documentation:
git help -g
7. View Config Options for Any Area
To see all Git configuration entries:
git help config
Example: see available merge strategies:
git help merge
Example: show all commit options:
git help commit
This is how you become proficient with Git internals.
8. Search Git Documentation
If you don’t know the exact command:
git help -a | grep stash
git help -a | grep rebase
Or use shell search:
apropos git
9. Diagnosing Errors With git help
Git error messages often mention:
See 'git <command> --help' for more information.
Examples:
Merge conflict:
error: Merging is not possible because you have unmerged files.
See 'git merge --help'
Fix:
git merge --help
You’ll find sections describing:
- what causes conflicts
- how to resolve
- merge strategies
10. Understanding Command Groups
Git help pages classify commands into groups:
Main commands
Daily operations:
- clone
- commit
- push
- pull
- merge
- status
Ancillary commands
Less frequent:
- bisect
- tag
- rebase
- revert
- branch
Plumbing commands (advanced)
Underlying low-level tools:
- update-index
- hash-object
- cat-file
- fsck
DevOps teams rarely need these, but they are great for deep learning.
11. HTML Documentation
Git can open documentation in the browser:
git help -w log
git help -w commit
The -w flag forces a web browser help viewer.
12. Example: Exploring an Unknown Command
Suppose you see git worktree in an article — and don’t know it.
Just run:
git help worktree
You get:
- Concept explanation
- Examples
- Options
- Workflows
This is the fastest way to learn new commands.
13. Example: Learning Commit Ranges
Want to understand HEAD~3 or main..develop?
Run:
git help revisions
This is the official & complete explanation.
14. Example: Learn Basic Git Concepts
git help tutorial
git help tutorial-2
git help everyday
It’s surprising how many professionals never read these.
15. Summary – Git Help Commands
| Purpose | Command |
|---|---|
| Full docs for command | git help <cmd> |
| Short usage | <cmd> -h |
| Open help in browser | git help -w <cmd> |
| All commands | git help -a |
| All guides | git help -g |
| Manual pages | man git-<cmd> |
| Config reference | git help config |
| Glossary | git help glossary |
16. Why Git Help Matters in DevOps
Git is central to DevOps workflows:
- CI/CD triggers
- IaC versioning
- PR reviews
- Rollbacks
- Deployment tagging
- Artifact tracking
Being able to quickly reference documentation speeds up troubleshooting and reduces mistakes.
17. What’s Next?
You now know how to:
✔ Explore any Git command
✔ Understand man pages
✔ Read guides & examples
✔ Diagnose errors
✔ Learn Git on your own from the CLI
The next chapter: