gerrit 使用中踩過的小坑

gerrit 使用中踩過的小坑

gerrit 不能推送 merge

git push origin HEAD:refs/for/master

  Counting objects: 203, done.
  Delta compression using up to 4 threads.
  Compressing objects: 100% (37/37), done.
  Writing objects: 100% (59/59), 6.84 KiB | 0 bytes/s, done.
  Total 59 (delta 26), reused 0 (delta 0)
  remote: Resolving deltas: 100% (26/26)
  remote: Processing changes: refs: 1, done
  To ssh://[email protected]:29418/xxxrowd
  ! [remote rejected] HEAD -> refs/for/master (you are not allowed to upload merges)
  error: 無法推送一些引用到 'ssh://[email protected]:29418/xxxrowd'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

解決辦法

git rebase
  Cannot rebase: You have unstaged changes.

git stash
# 每次 push 前
git pull --rebase
git push origin HEAD:refs/for/master
# gerrit review
git pull
git stash pop
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

因在 master 上開發,導致和遠程衝突,這時 Git pull 默認 merge 模式 
gerrit 不允許 merge 後提交,需 rebase 方式,所以,本地 pull 以 rebase 方式進行,即: 
git pull –rebase

gerrit review 報錯

Code Review - Error
The change could not be merged due to a path conflict.
Please rebase the change locally and upload the rebased commit for review.
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

處理

git stash
# 每次 push 前
git pull --rebase
git stash pop
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

eclipse 黑星:已暫存,存在於 INDEX 中。

未添加 .ignore 文件前使用 git add . 將所有文件添加到庫中,不小心將一些不需要加入版本庫的文件加到了版本庫中。此時還沒有提交所以不存在 HEAD 版本,不能用 git reset HEAD

git rm -r –cached .

服務器部署裸庫,什麼是裸庫?

其實就是 .git 目錄

git clone –bare my_project my_project.git

等價於

cp -Rf my_project/.git my_project.git


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章