GIT REFERENCE · INTERVIEW & DAILY DEVOPS USE
GIT COMMAND MASTER MAP
From Beginner to Senior DevOps Engineer — every command mapped to where it actually operates in the Git lifecycle, not just listed alphabetically.
Starts here
Remote Repository
Pull Request→
Code Review→
Merge→
CI/CD→
Deployment
Working Directory
Staging Area
Local Repository
Remote Repository
Debug / Advanced
Destructive — use with care
01Setup & Configurationone-time / global
Runs before any repository exists — configures Git itself.
git --versionCheck installed Git version.
git config --global user.name "Name"Configure your commit username.
git config --global user.email "email"Configure your commit email.
git config --listView current Git configuration.
git help <command>Get help for any command.
02Create / Get a Repositorylocal repository
The two entry points into version control.
git initConvert the current folder into a Git repository.
git clone <url>Download an existing remote repository.
MEMINIT = start new · CLONE = copy existing
03Check Changesworking dirstaging
Inspect state before you act — the "what's going on" commands.
git diffShow unstaged changes.
git diff --stagedShow staged changes.
git log --onelineCompact commit history.
git show <commit>Inspect a single commit in detail.
MEMSTATUS=what? DIFF=what's different? LOG=what happened? SHOW=show me that commit
04Stagingstaging area
Working Directory → Staging Area.
git add file.txtStage one file.
git add .Stage everything.
git restore --staged file.txtRemove a file from staging.
MEMADD = prepare for commit
05Commitlocal repository
Staging Area → Local Repository.
git commit -m "message"Create a commit.
git commit -am "message"Stage tracked files and commit in one step.
git commit --amendModify the previous commit.
MEMCOMMIT = local checkpoint
06Branchinglocal repository
Parallel lines of development inside the local repo.
git branch feature/loginCreate a branch.
git switch feature/loginSwitch to a branch.
git switch -c feature/loginCreate and switch in one step.
git checkout <branch>Older way to switch branches.
git branch -d feature/loginDelete a merged branch.
git branch -D feature/loginForce-delete a branch.
MEMBRANCH = parallel development · SWITCH = move between branches
07Merginglocal repository
Combine two branch histories into one.
git merge feature/loginMerge a branch into the current branch.
git merge --abortCancel a conflicted merge.
main ─────A────B────────M
\ /
feature C────D───┘
MEMMERGE = combine histories
08Remote Repositoriesremote
Local Repository ⇄ Remote Repository.
git remote -vShow configured remotes.
git remote add origin <url>Connect a remote repository.
git fetchDownload remote info WITHOUT merging.
git pullFetch + integrate remote changes.
git push -u origin branchFirst push + set upstream tracking.
MEMFETCH = download, don't integrate · PULL = download + integrate · PUSH = upload
09Undo / Recoveryworking dirlocal repo
The three most confused commands in Git — separated by exactly what they undo.
git restore file.txtDiscard working-directory changes.
git restore --staged file.txtUnstage a file.
git revert <commit>Create a new commit that reverses an old one.
git reset --soft HEAD~1Remove commit, keep changes staged.
git reset HEAD~1Remove commit, keep working changes.
git reset --hard HEAD~1Remove commit AND changes — unrecoverable via normal means.
MEMRESTORE = files · RESET = move local history · REVERT = safely undo committed history
⚠git reset --hard — Destructive. Uncommitted and committed changes past this point can be permanently lost. Prefer revert on shared branches.
10Stashworking dir
Temporary shelf for unfinished changes.
git stashTemporarily store unfinished changes.
git stash listList stashes.
git stash popRestore + remove latest stash.
git stash applyRestore but keep the stash.
git stash dropDelete a stash.
MEMSTASH = temporary shelf
11Rebaselocal repository
Replay commits for a clean, linear history.
git rebase mainReplay commits on top of main.
git rebase -i HEAD~3Interactive history cleanup.
git rebase --continueContinue after resolving a conflict.
git rebase --abortCancel the rebase.
Before:
main A──B──C
\
feature D──E
After rebase:
main A──B──C──D'──E'
MEMREBASE = replay / clean linear history
12Cherry-Picklocal repository
Copy one specific commit onto the current branch.
git cherry-pick <commit>Copy one specific commit onto the current branch.
Branch A: A──B──C
│
Branch B: D──E──C' ◄── copied
MEMCHERRY-PICK = pick one commit
13Tagslocalremote
Mark release points in history.
git tag v1.0Create a lightweight tag.
git tag -a v1.0 -m "Release v1.0"Create an annotated release tag.
git push origin v1.0Push a single tag.
git push origin --tagsPush all tags.
14File Managementworking dir
git rm file.txtRemove a tracked file.
git mv old.txt new.txtRename or move a tracked file.
.gitignoreFiles Git should ignore entirely.
15Conflict Resolutionworking dirlocal repo
Triggered by pull / merge / rebase when histories collide.
CONFLICT
→
open conflicted files
→
choose / fix correct code
→
git add <file>
→
git commit (or rebase --continue)
<<<<<<< HEAD
current code
=======
incoming code
>>>>>>> feature
MEMFIX → ADD → CONTINUE/COMMIT
16Debugging / Advanced Commandsforensics
For when something already went wrong.
git blame <file>Who changed each line?
git bisect startBinary-search which commit introduced a bug.
git reflogHistory of HEAD movements — recover "lost" commits.
git clean -nPreview untracked files that would be removed.
git clean -fdRemove untracked files and directories — permanent.
MEMBLAME = who changed it? · BISECT = which commit broke it? · REFLOG = where was HEAD?
⚠git clean -fd — Destructive. Deletes untracked files/folders with no recovery path. Always run -n first.
17Daily DevOps Workflowend-to-end
What a typical feature ticket looks like in practice, clone to production.
git clone
↓
git switch -c feature/JIRA-123
↓
modify code
↓
git status
↓
git diff
↓
git add .
↓
git commit -m "JIRA-123: change"
↓
git pull --rebase
↓
git push -u origin feature/JIRA-123
↓
Pull Request
↓
Code Review
↓
Merge
↓
CI Pipeline — Build → Test → Security Scan
↓
CD Pipeline — DEV → QA/UAT → PROD
18Most Important Memory Mapsummary
If you remember nothing else, remember this chain.
↓
↓
↓
↓
↓
COLLABORATE
branch · switch · merge · rebase
↓
↓
UNDO
restore · revert · reset
↓
RECOVER / DEBUG
reflog · blame · bisect
↓
"Git is easier to remember when you understand WHERE a command acts."
Working Directory → Staging → Local Repository → Remote Repository
ADD → COMMIT → PUSH — the core save chain
FETCH — download only
PULL — download + integrate
STASH — temporary save
RESTORE — file undo
REVERT — safe commit undo
RESET — move history
REBASE — replay history
CHERRY-PICK — copy one commit
REFLOG — recover history