git 命令

1.添加远程仓库(先有本地仓库,后有远程仓库)

  git remote add origin 远程仓库地址

2.推送到远程仓库(第一次推送)

  git push -u origin master

3.远程仓库克隆

  git clone 远程仓库地址

4.查看远程仓库

  git remote -v

5. 查看分支 git branch

6.创建分支  git branch <name>

7.切换分支 git checkout <name>

8.创建&&切换分支 git checkout -b <name>

9.合并分支 git merge <name>

10. 删除分支 git branch -d <name>  强制删除 git branch -D <name>

11. 新建分支并且将远程分支拉取到新分支

  git checkout -b <新分支> --track origin/develop

12.查看分支合并图 git log --graph

13. 合并分支 (将dev 分支合并到master)

  1> git checkout -b dev (新建分分支)

  2> git commit -a -m 'fix hint' (提交修改文件)

  3> git checkout master (切换到master)

  4> git merge --no-ff  -m 'hint' dev (将dev 合并到master)

14. 缓存信息 : git stash

  查看缓存: git stash list

  恢复缓存: git stash apply

  删除缓存: git stash drop

  恢复并删除缓存: git stash pop

  恢复指定的stash: git stash apply stash{0}

15. 版本回退

  git reset --hard commitid

16.将文件移除版本控制

  删除文件: git rm -rf --cached 文件名 

  提交删除文件: git commit -m 'hint'

  提交远程分支: git push origin master

  将文件名添加到 .gitignore

  提交 .gitgnore

原文地址:https://www.cnblogs.com/xiaoyao181/p/8797410.html