workspace:工作区
staging area:暂存区/缓存区
local repository:版本库或本地仓库
remote repository:远程仓库
-
git init [指定目录]
创建仓库 -
git add *.c
对.c文件进行跟踪 -
git clone [git仓库] | [本地目录]
拷贝项目 -
git config
配置 -
git config --global user.name "myName"
-
git config --global user.email ...com
设置提交代码用户信息 -
cat README.md
查看文件内容 -
git branch (branchname)
创建分支 -
git branch
列出分支 -
git checkout (branchname)
切换分支 -
git merge
将任何分支合并到当前分支中 -
git commit -m '版本提交'
提交 -
git checkout -b (branchname)
创建新分支并切换到该分支下 -
git branch -d (branchname)
删除分支 -
git log
查看历史提交记录 -
git blame [file]
查看指定文件修改记录 -
git tag [-a] v1.0
创建带注解(-a)的标签 -
git fetch
从远程仓库下载新分支与数据,接着要 -
git merge
从远端仓库提取数据并合并到当前分支 -
git push [alias] [branch]
将 [branch] 分支推送成为 [alias] 远程仓库上的 [branch] 分支 -
git remote -v
添加删除远程仓库
origin git@github.com:tianqixin/runoob-git-test.git (fetch)
origin git@github.com:tianqixin/runoob-git-test.git (push) -
git remote add origin2 git@github.com:tianqixin/runoob-git-test.git
-
git remote -v
origin git@github.com:tianqixin/runoob-git-test.git (fetch)
origin git@github.com:tianqixin/runoob-git-test.git (push)
origin2 git@github.com:tianqixin/runoob-git-test.git (fetch)
origin2 git@github.com:tianqixin/runoob-git-test.git (push) -
git remote rm origin2
-
git remote -v
origin git@github.com:tianqixin/runoob-git-test.git (fetch)
origin git@github.com:tianqixin/runoob-git-test.git (push)