git 保存密码 禁用改换行符 等常用操作

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提交即完成子模块的添加

  1. repo使用
    repo forall -p -c "git status" 列出所有仓库并执行git status

  2. 关闭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
    证书报错问题

  1. WSL使用git拉下来的仓库文件换行都变成dos问题
git config --global core.autocrlf false
  1. 推送了错误的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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容