標籤:style blog http io ar color os 使用 sp
遇到過很多種Git許可權的問題,其中有一種就是因為Git採用了二次驗證之後需要SSL授權的key才可以有許可權pull,push。之前使用SourceTree來Clone項目,但是坑就在這裡,一不小心選擇了Https的連結,那麼拉下來的項目就是HTTPs,再後來切換到二次驗證之後就各種許可權錯誤。
那麼一不小心範了這樣的錯誤怎麼辦,刪除掉項目重新拉一邊?如果已經開發了新的東西就很不方便了,這裡給出解決方案:
項目的根目錄下面有.git檔案,在終端下面進入項目,
然後開啟.git下面的config檔案:
nano .git/config
就可以看到這個項目的配置,如下面
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true[remote "origin"] url = https://github.com/xxx/test.git fetch = +refs/heads/*:refs/remotes/origin/*[branch "develop"] remote = origin merge = refs/heads/develop[branch "function_SSO_Login"] remote = origin merge = refs/heads/function_SSO_Login[branch "fix_crashlytics_bug"] remote = origin merge = refs/heads/fix_login_bug[branch "master"]
在url中將https的連結換成[email protected]:xxx/test.git就可以
一切就恢複了正常.
已經clone的Git項目從Https切換到SSL