關於gitlab的一個問題解決


這兩天折騰一個關於gitlab的問題,搞得比較焦頭爛額。不過經過折騰,最終還是成功了。

當面對着一個問題,並且看到還沒被解決的時候,感覺很不舒服;

努力折騰之后,解決之后,也會身體輕松。或許工程師天生就是"不解決問題不舒服斯基"。這是不好的習慣,以后要改。這里簡要記錄一下。

一.產生的問題描述:

  前兩天同事自己在gitlab上面創建了一個倉庫,http://121.201.13.32:9000/sbzhou/tsd-collector.git,由於所有peoject都基本是統一的前綴 http://121.201.13.32:9000/xiaobao/(例如http://121.201.13.32:9000/xiaobao/tsd-thirdparty.git),為了協調和統一性,我們建議統一管理:重建peoject

  操作步驟1.,我首先通過gitlab去transfer project,結果發現transfer之后,他無法提交;

  於是只好重新再次create project,create之后,上傳他原來的project code,依然會存在問題。

HaoChuang@LENOVO-PC /E/test/suyx/tsd-collect (master)
$ git push -u origin master
Username for 'http://121.201.13.32:9000': suyx
Password for 'http://suyx@121.201.13.32:9000':
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 553 bytes | 0 bytes/s, done.
Total 6 (delta 4), reused 0 (delta 0)
remote: GitLab: You don't have permission
To http://121.201.13.32:9000/xiaobao/tsd-collect.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://121.201.13.32:9000/xiaobao/tsd-collec
t.git'

二.解決過程:

1.查看系統配置,發現,這里說一下,同學們安裝gitlab的時候,可以才用這個安裝: bitnami-gitlab-7.6.2-0-linux-x64-installer.run

你可以通過如下命令啟動: ./ctlscript.sh start

另外,查看日志的話,可以去該位置查看:/home/git/gitlab-shell/gitlab-shell.log

/opt/gitlab-7.6.2-0/apps/gitlabci/htdocs/log/sidekiq.log

部分配置文件,可以根據這里查找:/opt/gitlab-7.6.2-0/properties.ini

參考:http://www.koofun.com/showcode.html?id=29706&l=en

 

這里標記幾個常用的命令,供各位參考:

Git global setup

git config --global user.name "haochuang"
git config --global user.email "hao@aituyou.com"

Create a new repository

mkdir tsd-collect
cd tsd-collect
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin git@121.201.13.32:xiaobao/tsd-collect.git
git push -u origin master

Push an existing Git repository

cd existing_git_repo
git remote add origin git@121.201.13.32:xiaobao/tsd-collect.git
git push -u origin master

三.最終解決辦法:

1.提升設備的配置;

2.修改了部分配置文件,增大了資源配置,確保http鏈接可用;

3.清除重復repo,確保服務器端干凈;

4.重建git倉庫,重新清理和檢查、調整權限;

 

四.問題原因分析和回顧:

  參考:https://bitbucket.org/site/master/issues/7522/remote-rejected-master-master-pre-receive

  重復會導致問題;

      需要添加SSH Public Key 到你的 GitLab:http://stackoverflow.com/questions/27457540/gitlab-password-and-permission

 

五.操作備注:

備注1:在第一次創建工程的時候,記得先作如下操作:

git remote add  origin git@github.com:<your name>/<appname>
第一次需要origin,添加repository,之后才向repository push你的代碼。
一般是push到github之后,再git push master部署到master上。

備注2:在使用git的時候,要了解git的基本使用flow,而且團隊中盡可能讓所有人都能正常了解和使用:

https://about.gitlab.com/2014/09/29/gitlab-flow/

 

備注3:對於工程的創建和刪除,最好是統一管理。

當然,最好的是公司能有自己的SCM人員,免得由於部分人操作失誤,出現問題之后,耽誤其他工程師幫忙修復,耽誤時間。

PS:對於一些號稱工作了15年,卻只會做點傳話筒的事情,只會用TororsieSVN GUI提交代碼,連git都用不好,用了也還個你挖坑,在工作中盡量與這種人越遠越好,免得受其影響,被帶出壞習慣 :-)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM