1, 基本命令
# 初始化 Git 仓库
git init
# 克隆远程仓库到本地
git clone https://github.com/user/repo.git
# 添加文件到暂存区
git add file.txt
# 提交更改到本地仓库
git commit -m "Added file.txt"
# 推送本地更改到远程仓库
git push origin master
# 拉取远程更改到本地仓库
git pull origin master
# 查看当前工作区和暂存区的状态
git status
# 查看提交历史
git log
# 创建新分支
git branch new_branch
# 切换分支
git checkout new_branch
# 合并分支
git merge other_branch
# 重置分支到指定提交
git reset --hard commit_hash
# 添加远程仓库
git remote add upstream https://github.com/other_user/repo.git
# 暂存当前工作区的更改
git stash
# 恢复之前暂存的更改
git stash apply
# 删除本地分支
git branch -d branch_name
# 撤销指定的提交
git revert commit_hash