DevOps
Git
Commands Reference

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

CommandActionLifecycle Phase
git initInitializes a new, empty Git repository.Setup
git clone [url]Downloads a project and its entire history from a URL.Setup
git statusShows 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 pushUploads local repository content to a remote repository.Collaborate
git pullFetches and merges changes from the remote to local.Collaborate
git logShows 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 stash If you need to switch tasks but aren't ready to commit, use git stash to temporarily "hide" your dirty changes. You can bring them back later with git stash pop.