| 命令 | 描述 |
|---|---|
git init |
初始化一个新的 Git 仓库 |
git clone [url] |
克隆一个远程仓库到本地 |
git status |
查看仓库状态 |
git add [file] |
把文件添加到暂存区 |
git add . or git add --all |
把所有改动添加到暂存区 |
git commit -m "[message]" |
提交暂存区到仓库 |
git commit -a -m "[message]" |
将所有更改(不包括未跟踪的文件)添加到暂存区并提交 |
git push [remote] [branch] |
推送改动到远程仓库 |
git pull [remote] [branch] |
从远程仓库拉取最新改动 |
git branch |
显示本地所有分支 |
git branch -a |
显示所有分支(包括远程分支) |
git branch [name] |
创建新分支 |
git branch -d [name] |
删除分支 |
git checkout [branch] |
切换到指定分支 |
git checkout -b [branch] |
创建新分支并立即切换过去 |
git merge [branch] |
合并指定分支到当前分支 |
git rebase [branch] |
将当前分支的改动移到指定分_branch_ |
git diff |
显示所有未添加到暂存区的更改 |
git diff --staged |
显示所有已添加到暂存区但还未提交的更改 |
git log |
显示提交历史 |
git log --oneline |
显示简化的提交历史 |
git revert [commit] |
撤销指定的提交 |
git reset --hard [commit] |
丢弃所有自指定提交以后的修改 |
git stash |
暂存当前工作区的改动 |
git stash pop |
恢复最近一次暂存的工作区改动 |
这只是一份基本的 Git 命令清单,Git 还有很多强大的高级功能等待您去发掘和学习。
