笔者每次新建仓库后首次同步都记不住操作,故干脆开篇博客记录一下
本地仓库首次推送
git init
touch README.md
git add .
也可以git remote add origin git@github.com:xxxxx/yyyyy.git
git commit -m "first commit"
git push -u origin master
- 如果推送失败,但是上面又没有什么必要的,可以使用强制推送
git push -f origin master
删除 github 仓库上的文件夹
git pull orint master
将远程仓库拉下来;dir
查看目录;git rm -r --cached 文件夹名
将指定文件夹删除;git commit -m '删除了XXX文件夹'
提交并添加操作说明;git push -u origin master
将本次操作推送到 github 上
遇到的问题
- 同步时出现
Permanently added the RSA host key for IP address 'xxx.xxx.xxx.xxx' to the list of known host
这个提示只是一个警告,对实际操作没有影响。若要取消这个提示,只需在 hosts 文件下添加一条记录就可以了:sudo vim /etc/hosts
打开之后,添加xxx.xxx.xxx.xxx github.com
,保存并关闭即可