1、初始化

git init

2、连接远程仓库

git remote add origin git@e.coding.net:custouch/Cusotuch.Customer.Sites.git
git remote rm origin (解除)

3、拉取远程分支

git pull origin 分支名
git pull origin 分支名 —allow-unrelated-histories 不推荐
git fetch origin //拉取所有远程分支

4、新建分支

git checkout -b 分支名

5、查看分支

git branch //查看本地分支
git branch -a //查看所有分支
git branch -r //查看远程分支

git branch -m old_branch new_branch //本地分支改名

6、切换分支

git checkout 分支名
git checkout -b 分支名
git checkout -b test origin/test

7、上传

git add . // 将修改内容加入缓存区
git commit -m “说明” //添加说明
git push origin 分支名 //上传到远程分支,如果没有新建
git push origin 分支名 -f //强制上传到远程分支,不推荐

8、状态管理

git status //显示有变更文件
git log //显示git历史

9、打标签

git tag -a V1.2 -m ‘release 1.2’ //创建本地版本 V1.2 ,并且添加附注信息 ‘release 1.2’
git tag //查看标签
git push origin —tags //提交到远程
git tag -d V1.2 //删除本地tag
git push origin :refs/tags/V1.2 //删除远程tag
git fetch origin tag V1.2 //获取远程的tag版本

10、删除分支

git branch -d dev20181018 //删除本地分支
git branch -D dev20181018 //强制删除本地分支
git push origin —delete dev20181018 //删除远程分支(慎用)

11、vscode插件

Git Graph
Git History Diff

12、连接gitee

  1. 1、生成ssh key
  2. ssh-keygen -t rsa -C"1009382084@qq.com"
  3. 2、复制ssh key
  4. vi /Users/zhanyuhan/.ssh/id_rsa.pub
  5. 3、复制到此处
  6. https://gitee.com/profile/sshkeys
  7. 4、连接gitee
  8. ssh -T git@gitee.com
  9. 5、新建文件夹,并拉取文件 参考链接中123拉取)
  10. https://www.yuque.com/cqcode/iegvyo/ovh8hu
  11. 6、如第5步遇报错执行下面命令即可
  12. git clean -f
  13. 7、完成