一、基本安装
1.安装本地git
阿里镜像:https://npm.taobao.org/mirrors/git-for-windows/v2.25.0.windows.1/
2.本地生成ssh公钥
教程
https://git-scm.com/book/zh/v2/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E7%94%9F%E6%88%90-SSH-%E5%85%AC%E9%92%A5
3.复制本地公钥到github账户
4.本地链接远程仓库
A.创建github仓库,复制仓库的SSH key
B.本地链接
教程:https://www.runoob.com/w3cnote/git-guide.html
Ps:解决 fatal: Not a git repository (or any of the parent directories): .git 问题
使用git init 创建.git 即可
二、基本使用
教程: https://www.runoob.com/w3cnote/git-guide.html
提交:
1.git clone 克隆远端仓库到本地
2.git add filename 本地修改的文件添加到缓存区 git status 查看状态
3.git commit -m filename 提交文件到本地仓库
4.git push origin master 推送主分支到远端仓库
分支相关:
- git checkout -m branch1name 创建并切换到分支1
- 提交到远端add -> commit -> push
- git checkout branch1name 切换分支
- git branch 查看分支
删除远端文件:
- git rm filename1
- git commit -am ‘delete remote file filename’
- git push origin branchname