gitee拉取分支,修改上傳出現的問題,折騰了好久,淺淺記錄.
1. 首次克隆倉庫
# 克隆倉庫(使用 HTTPS 或 SSH)
git clone ------------
cd xxx-project
2. 配置正確的用戶信息(關鍵步驟!)
# 設置全局用戶名和郵箱(必須與 Gitee 賬號綁定郵箱一致)
git config --global user.name "你的真實姓名"
git config --global user.email "你的Gitee驗證郵箱"# 檢查配置
git config --list
3. 拉取遠程分支
# 獲取所有遠程分支信息
git fetch origin# 查看可用分支
git branch -r# 創建本地分支并關聯遠程分支(示例:English-branch)
git checkout -b English-branch(bendi) origin/English-branch(yuancehn)
4. 修改代碼并提交
# 修改文件后...
git add .
git commit -m "描述你的修改"
5. 推送到遠程倉庫
# 首次推送(建立關聯)
git push -u origin English-branch# 若推送被拒絕(因歷史提交問題)
git push -f origin English-branch # 強制推送(僅限個人分支使用!)
關鍵問題解決方案
錯誤原因
remote: Push will publish a hidden email, make email public or abandon related commits
remote: error: hook declined to update refs/heads/English-branch
- 原因:Gitee 檢測到提交中的郵箱是隱藏的(如 GitHub 的
noreply
郵箱)或未驗證 - 解決:
- 確保
git config
中的郵箱與 Gitee 賬號綁定且已驗證 - 修改歷史提交中的錯誤郵箱(見步驟5)
- 確保
驗證郵箱是否有效
- 登錄 Gitee → 進入「設置」→「郵箱管理」
- 確認:
- 郵箱已驗證
- 郵箱與
git config user.email
完全一致
我的解決方案
gitee進去個人設置頁->郵箱管理->公開郵箱或取消命令上傳的權限。over 🚀