步骤
- 新建本地仓库:git init
- 确定上传所有文件:git add .
- 本地commit:git commit
- 连接远程仓库:git remote add origin https://github.com/sinkinben/Asm-Lab
origin是远程仓库的简称,后面是地址
- 查看是否添加成功:git remote -v
- 远程与本地合并:git pull origin master
- 本地master上传:git push -u origin master
如果是添加了新文件,需要push,则
|
其他操作
- 删除本地仓库
直接删除.git文件夹
- 添加ignore
问题总结
- fatal:HttpRequestException encountered
Github禁用了TLS v1.0 and v1.1这种弱加密标准,此时需要手动更新Windows的git凭证管理器,更新方式很简单,在网站下载Git在Window上的凭证管理器并默认安装即可。
link:https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/
下载安装。
- fatal: refusing to merge unrelated histories
解决办法:git pull origin master --allow-unrelated-histories
- warning: LF will be replaced by CRLF
Unix和Windows下换行符不一致造成的。
转换为Windows格式 | unix2dos file |
转换为Unix格式 | dos2unix file |
- git commit无反应
可能的原因是已经提交一了一个commit,该进程卡在这里了,所以无法继续提交。
解决办法:rm -f ./.git/index.lock