指令速查
雷区勿踩
常见错误和小技巧
git pull失败,提示:fatal: refusing to merge unrelated histories
1 | git pull origin master --allow-unrelated-histories |
git add 添加文件夹而非全部修改文件
1 | 添加整个文件夹及内容 |
与fork别人的仓库保持同步
- 将fork的项目添加到remote中
1
git remote add your_forked_project_name(whatever you like) https://your_forked_project_url.git
- 更新remote中所有远程repo
1
git fetch --all
- 进行同步
1
git rebase your_forked_project_name/master
- 将自己的远程仓库也同步
1
git push origin master
处理 github 不允许上传超过 100MB 文件的问题
移除错误缓存
1 | # for file |
重新提交后将大文件加入 Git Large File Stroage:
- 安装git-lfs:
brew install git-lfs
- 在repository的根目录初始化:
git lfs install
- 跟踪大文件名:
git lfs track "name_of_your_giant_file_not_your_path!"
- 正常提交推送:
git add your_giant_file_path
- 搜索大文件:
find ./ -size +100M
git commit后想要撤销到上一个commit
1 | git reset --soft HEAD^ |
git push 提交代码时writing objects特别慢解决方案
1 | git config --global http.postBuffer 524288000 |
引用参考资料和版权说明
- http://www.git-tower.com/blog/git-cheat-sheet-cn
- https://blog.csdn.net/wxs0124/article/details/50126953
- http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories
- https://blog.csdn.net/xinqingwuji/article/details/79391453
- https://www.cnblogs.com/-walker/p/7278951.html
- https://blog.csdn.net/smart_graphics/article/details/78475735
- http://www.liuxiao.org/2017/02/git-%E5%A4%84%E7%90%86-github-%E4%B8%8D%E5%85%81%E8%AE%B8%E4%B8%8A%E4%BC%A0%E8%B6%85%E8%BF%87-100mb-%E6%96%87%E4%BB%B6%E7%9A%84%E9%97%AE%E9%A2%98/
- https://blog.csdn.net/w958796636/article/details/53611133