内卷地狱

Git Getting Started Guide — Git Tips Every Developer Should Know

Edit Me

Most Common Git Commands

BasicBranch & Remote
git init <dir> → Initialize a repogit branch → List / create branches
git clone <repo> → Clone a remote repogit checkout -b <branch> → New branch + switch
git add <file> → Stage a filegit merge <branch> → Merge a branch
git commit -m "msg" → Commit changesgit pull <remote> → Fetch + merge remote
git push <remote> <branch> → Push branchgit remote add <name> <url> → Add remote
git status → Check file statusgit fetch <remote> <branch> → Fetch remote branch
git log --oneline → One-line historygit pull --rebase <remote> → Fetch + rebase
git diff → View unstaged changesgit push <remote> --tags → Push all tags

Other Git Commands

Undo / Reset / Log / DiffConfig / Advanced Push / Rebase
git commit --amend → Modify the last commitgit config user.name <name> → Set repo author name
git revert <commit> → Revert a commitgit config --global user.name <name> → Global author name
git reset <file> → Unstage a filegit config --global user.email <email> → Global email
git reset --soft <commit> → Roll back commit, keep staged & workinggit config --global alias.<alias> <cmd> → Create alias
git reset --mixed <commit> → Roll back commit, keep working (default)git config --system core.editor <editor> → Set editor
git reset --hard <commit> → Roll back commit, discard changesgit config --global --edit → Edit global config
git clean -n → Preview deletion of untracked filesgit push <remote> --force → Force push (dangerous)
git reflog → View HEAD historygit push <remote> --all → Push all branches
git log -<n> → Limit number of commitsgit rebase <base> → Rebase a branch
git log --stat → File change statsgit rebase -i <base> → Interactive rebase
git log -p → Detailed commit diffgit rebase --continue → Continue rebase after conflict
git log <since>..<until> → History in a rangegit rebase --abort → Abort rebase
git log -- <file> → History for a specific filegit log --author="<pattern>" → Search by author
git diff HEAD → Working tree vs. latest commitgit log --grep="<pattern>" → Search by message
git diff --cached → Staged vs. latest commitgit log --graph --decorate → Graphical history

Practice Exercises

Here's a recommended interactive sandbox for learning Git — great for beginners to get hands-on quickly: https://learngitbranching.js.org/


贡献者


这篇文章有帮助吗?

最近更新

Involution Hell© 2026 byCommunityunderCC BY-NC-SA 4.0CCBYNCSA