Git Common Commands Quick Reference: Pull, Push, and Branch Switching All in One

Git is a version control tool that can record file modifications, revert versions, and support multi - person collaboration. The commonly used commands are as follows: Basic operations: Use `git init` to initialize a local repository, and `git clone 地址` to clone a remote repository. Daily operations: `git status` to check the file status, `git add` to stage modifications (use `git add .` to stage all changes), and `git commit -m "message"` to commit to the local repository. Branch operations: `git branch` to view branches, `git checkout -b 分支名` to create and switch to a branch, and `git merge 分支名` to merge branches. Pull and push: `git pull 远程 分支` to pull code, and `git push 远程 分支` to push (add `-u` for the first time). Undo and recovery: `git checkout -- 文件` to undo uncommitted modifications, and `git reset --soft HEAD~1` to revert the last commit (retaining modifications). Notes: The commit message should be clear, follow the branch naming conventions, always `pull` before collaboration to avoid conflicts, and use `git reset --hard` with caution. Core commands: `init`, `clone`, `add`, `commit`, `status`, `checkout`, `merge`

Read More