今天在創建 git 倉庫后,我試用 sourcetree 拉取倉庫后, 創建了一個分支后,按照正常的操作提交新分支代碼,但是報出了下面的錯誤內容:
Pushing to https://github.com/J-Boos/J-Boss-Tool.git
remote: You must verify your email address.
remote: See https://github.com/settings/emails.
fatal: unable to access 'https://github.com/J-Boos/J-Boss-Tool.git/': The requested URL returned error: 403
搗鼓了一番后找到了問題根源,是因為創建倉庫的時候 .git/config 文件沒有賬號密碼,只需要在 config 文件加上賬號密碼就行了;
具體步驟 :
第一步、 找到 .git 文件夾 如果是 mac 需要在項目文件 按下 shift + command + . 三個按鈕,你將會看到隱藏文件。
第二步、找到 git 文件夾 內的 config 文件,找到下面這段代碼 標橙色的 域名。
[remote "origin"]
url = https://github.com/J-Boss-Os/J-Boss-Tool.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
第三步、 把域名替換成 賬戶@密碼 后保存
[remote "origin"]
url = https://賬戶@密碼/J-Boss-Os/J-Boss-Tool.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
保存關閉編輯器后,重新 git push 你就會發現不會再報403 錯誤了