在本地创建项目完成后
$ git init # 初始化项目
在远程仓库创建项目
在本地仓库中关联远程仓库
$ git remote add origin 远程库地址
拉取在远程仓库中创建的文件,使得本地同远程仓库同步
$ git pull --rebase origin master
之后就可以进行
$ git add .
$ git commit -m‘xxx‘
$ git push
...
找到要回退的commit版本号并复制
$ git log # 按Q退出
本地库版本回退
$ git reset --hard [commitid]
同步到远端仓库
$ git push -f origin [branchName]
创建本地分支xxx
$ git checkout -b xxx
# 上面的命令是以下命令的简写
$ git branch xxx # 创建分支
$ git checkout xxx # 切换分支
将本地分支推送至远程仓库
$ git push -u origin xxx
提交xxx分支
# 在做出修改或添加文件后
$ git commit -a -m ‘fixed the broken email address‘
推送至远程仓库
$ git push
合并xxx分支到master主分支
$ git checkout master
$ git merge xxx
删除分支xxx
$ git branch -d xxx
原文:https://www.cnblogs.com/code-duck/p/13228508.html