1.运行命令,首次拉仓库输入用户名密码,然后就会永久保存到~/.git-credentials
git config --global credential.helper store
2.改变git提交中附带的用户消息
git config --global user.name "name"
git config --global user.email "mail@qq.com"
3.只拉去最新一层代码
git clone --depth=1
4.git添加子仓库
git submodule add <url> <path>
git submodule add <url> <path>
其中,url为子模块的路径,path为该子模块存储的目录路径。
执行成功后,git status会看到项目中修改了.gitmodules,并增加了一个新文件(为刚刚添加的路径)
git diff --cached查看修改内容可以看到增加了子模块,并且新文件下为子模块的提交hash摘要
git commit提交即完成子模块的添加
repo使用
repo forall -p -c "git status" 列出所有仓库并执行git status关闭ssl验证
git config --global http.sslverify false
解决fatal: unable to access 'https://github.com/ZLMediaKit/ZLMediaKit.git/': server certificate verification failed. CAfile: none CRLfile: none
证书报错问题
- WSL使用git拉下来的仓库文件换行都变成dos问题
git config --global core.autocrlf false
- 推送了错误的commit到远程仓库,想删除
(推荐)无强推权限,只能
git revert <bad-commit-hash-1>
git revert <bad-commit-hash-2>
git push origin <your-branch>
不想要历史记录。但需要强推权限
git reset --hard HEAD~2 #移除最新的两个提交(破坏历史)
或
git reset --hard <commit-hash> #重置到指定提交
git push --force-with-lease origin <your-branch> #强制推送 --force-with-lease
git push --force origin <your-branch>