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為該子模塊存儲的目錄路徑。

執(zhí)行成功后,git status會看到項目中修改了.gitmodules,并增加了一個新文件(為剛剛添加的路徑)

git diff --cached查看修改內(nèi)容可以看到增加了子模塊,并且新文件下為子模塊的提交hash摘要

git commit提交即完成子模塊的添加

  1. repo使用
    repo forall -p -c "git status" 列出所有倉庫并執(zhí)行g(shù)it status

  2. 關(guān)閉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到遠程倉庫,想刪除

(推薦)無強推權(quán)限,只能

git revert <bad-commit-hash-1>
git revert <bad-commit-hash-2>
git push origin <your-branch>

不想要歷史記錄。但需要強推權(quán)限

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>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容