【快速上手】Git的使用教程

创建Git仓库

git init

查看当前仓库情况

git status

添加修改

git add (file) or git add .

查看未提交的修改

git diff

撤销提交操作

git reset

提交自己的身份

git config --global user.name "xxx"
git config --global user.email "xxx@xxx.com"

向git提交内容

git commit -m ""

将本地仓库变为远程仓库

git remote add origin (adress)

忽略提交文件

touch .gitignore  and add files to .gitignore

不再追踪某个文件

git rm --cached (file)

添加分支

git branch (name)

切换分支

git  checkout (name)

合并分支

git merge (name)

列出本地分支

git branch -a

删除分支

git branch -d (name)  or -D(Mandatory deletion)

设置本地分支追踪远程分支

git push --set-upstream
原文地址:https://www.cnblogs.com/huanhao/p/usegit.html