GIT 使用 ¶
Top 37 Git Commands Every DevOps Engineer Must Know
🔹 Daily Workflow (Basics)
1.git clone – Copy repo locally
2.git status – Check repo state
3.git pull – Fetch & merge changes
4.git push – Push commits to remote
5.git add – Stage changes
6.git commit – Save changes
🔹 Branching & Collaboration
7.git branch – List branches
8.git branch
9.git checkout
10.git checkout -b
11.git switch – Switch branches (modern)
12.git merge – Merge branches
13.git rebase – Reapply commits cleanly
🔹 History & Inspection
14.git log – Commit history
15.git log --oneline --graph – Visual history
16.git diff – Show changes
17.git show – Inspect commit
18.git blame – Who changed what
🔹 Undo & Recovery (Very Important)
19.git reset – Undo commits (local)
20.git reset --hard – Force reset
21.git revert – Safe undo (prod-friendly)
22.git stash – Save uncommitted work
23.git stash pop – Restore stashed work
24.git reflog – Recover lost commits
🔹 Remote & Repo Management
25.git remote -v – View remotes
26.git fetch – Fetch without merge
27.git tag – Create version tag
28.git describe – Version info from tags
🔹 DevOps Power Commands
29.git cherry-pick – Pick specific commit
30.git clean -fd – Remove untracked files
31.git config – Git configuration
32.git shortlog – Commit summary
33.git archive – Create source archive
🔹 CI/CD & Ops Friendly
34.git diff HEAD~1 – Compare last commit
35.git rev-parse HEAD – Get commit hash
36.git show-ref – List refs
37.git worktree – Multiple working trees
Knowing Git deeply = fewer CI/CD failures & faster production fixes.
评论
请登录后发表评论。
暂无评论。成为第一个评论者!