Commands Reference
This table serves as a quick-start guide for the most frequently used Git commands in a DevOps engineer's daily workflow.
Essential Git Commands
| Command | Action | Lifecycle Phase |
|---|---|---|
git init | Initializes a new, empty Git repository. | Setup |
git clone [url] | Downloads a project and its entire history from a URL. | Setup |
git status | Shows which files are modified or staged. | Monitor |
git add [file] | Moves a file from the Working Directory to the Staging Area. | Prepare |
git commit -m "[msg]" | Saves the staged snapshot to the Local Repository. | Save |
git push | Uploads local repository content to a remote repository. | Collaborate |
git pull | Fetches and merges changes from the remote to local. | Collaborate |
git log | Shows the history of all commits in the current branch. | Inspect |
Command Lifecycle
Practical Example: A Normal Day
# 1. Update your local code from the team
git pull
# 2. Check what you're working on
git status
# 3. Stage your specific changes
git add config.yaml
git add scripts/deploy.sh
# 4. Save the snapshot
git commit -m "feat: added secondary region support to deploy script"
# 5. Share with the team
git push[!TIP]
git stashIf you need to switch tasks but aren't ready to commit, usegit stashto temporarily "hide" your dirty changes. You can bring them back later withgit stash pop.