這兩天折騰一個關於gitlab的問題,搞得比較焦頭爛額。不過通過折騰,最終仍是成功了。html
當面對着一個問題,而且看到還沒被解決的時候,感受很不舒服;linux
努力折騰以後,解決以後,也會身體輕鬆。或許工程師天生就是"不解決問題不舒服斯基"。這是很差的習慣,之後要改。這裏簡要記錄一下。git
一.產生的問題描述:github
前兩天同事本身在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),爲了協調和統一性,咱們建議統一管理:重建peojectshell
操做步驟1.,我首先經過gitlab去transfer project,結果發現transfer以後,他沒法提交;服務器
因而只好從新再次create project,create以後,上傳他原來的project code,依然會存在問題。app
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'
二.解決過程:ide
1.查看系統配置,發現,這裏說一下,同窗們安裝gitlab的時候,能夠才用這個安裝: bitnami-gitlab-7.6.2-0-linux-x64-installer.rungitlab
你能夠經過以下命令啓動: ./ctlscript.sh startspa
另外,查看日誌的話,能夠去該位置查看:/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都用很差,用了也還個你挖坑,在工做中儘可能與這種人越遠越好,省得受其影響,被帶出壞習慣 :-)