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提交即完成子模塊的添加
repo使用
repo forall -p -c "git status" 列出所有倉庫并執(zhí)行g(shù)it status關(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
證書報錯問題
- WSL使用git拉下來的倉庫文件換行都變成dos問題
git config --global core.autocrlf false
- 推送了錯誤的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>