基础

git init #新建仓库
git add 文件名  #加入到修改区
git commit -m "first submit" #将修改的提交
git status #检查文件状态
git log #查看分支记录

建立链接

git clone 地址 #克隆仓库
git remote add origin 地址 #与远程仓库建立连接
git remote -v #检查所有远程的配置服务器

用户信息

git config --global user.name "kiudou" #用户名
git config --global user.email "qidong120@hotmail.com" #用户邮箱
git config --list #输出用户的信息

分支

git branch #列出分支
git checkout -b '分支名' #创建并使用分支
git branch -d '分支名' #删除分支
git checkout '分支名' #切换到该分支
git push origin '分支名' #推送分支到远程仓库
git merge '分支名' #合并另一个分支到当前活动分支
git push origin --delete <branchName> #删除远程分支1.7.0版本后使用
git push origin :<branchName> #删除远程分支,推送一个空分支到远程分支

tag

git tag #打出所有标签 
git tag -a 标签名 #轻量标签
git tag -a 标签名 -m "说明" #附注标签
git tag -d 标签名 #删除本地仓库标签
git push origin :refs/tags/标签名 #删除远程一个标签
git push origin 标签名 #向远端提交当前标签
git push origin --tags #向远端提交所有标签

推送和更新

git push origin master #向远端提交master分支做的变更
git push origin '分支名' #向远端提交该分支的变更
git push -all origin #向远端提交所有分支
git pull #从远端服务器更新到本地

删除

git rm 文件名 #删除文件