Git 常見問題整理

來源:互聯網
上載者:User

標籤:use   rem   pass   tween   stat   協議   .com   it服務   any   

在學習git的過程中,遇到如下問題,特整理如下:

1 error:src refspec master does not match any

問題產生

a git伺服器使用如下命令建立一個項目

$ cd /opt/git$ mkdir project.git$ cd project.git$ git --bare init

b 用戶端clone代碼並提交

$ cd myproject$ git init$ git add .$ git commit -m ‘initial commit‘$ git remote add origin [email protected]:/opt/git/project.git$ git push origin master

c push報錯 

原因分析

引起該錯誤的原因是,目錄中沒有檔案,空目錄是不能提交上去的

解決辦法

touch READMEgit add README git commit -m ‘first commit‘git push origin master
2 fatal: unable to connect to eagain.net

問題產生

使用git clone 命令從 eagain.net 複製gitosis.git源碼出錯

解決辦法

git clone git://github.com/res0nat0r/gitosis.git
3 fatal:Interactive git shell is not enabled

問題產生

a 設定git使用者登入shell

作為一個額外的防範措施,你可以用Git 內建的git-shell 簡單工具來把git 使用者的活動限制在僅與Git 相關。把它設為git 使用者登入的shell,那麼該使用者就不能擁有主機正常的shell 訪問權。為了實現這一點,需要指明使用者的登入shell 是git-shell ,而不是bash 或者csh。你可能得編輯/etc/passwd 檔案:

sudo vim /etc/passwd

找到git使用者的資訊,修改如下:

儲存修改後,使用如下命令訪問伺服器

ssh [email protected]

報錯如下:

原因分析

按照提示,在git使用者的主目錄下面需要存在git-shell-commands目錄

解決辦法

在git使用者的主目錄下面建立git-shell-commands目錄

參考連結

http://planzero.org/blog/2012/10/24/hosting_an_admin-friendly_git_server_with_git-shell

4 通過http協議clone出錯

問題產生

在gitserver通過apache提供了git項目的公用訪問地址,在複製的時候報錯如下:


解決辦法

在git伺服器上要提供的項目下面執行

git update-server-info
5  centos5.8下面安裝gitweb的預設路徑問題

問題產生

在centos下使用yum install gitweb 命令安裝gitweb後找不到gitweb的預設安裝路徑

原因分析

網路上的說法預設路徑是 /var/www/git ,但是在我的centos虛擬機器中,安裝完gitweb後,預設路徑是/usr/share/gitweb

解決辦法

由於按網上的說法,找不到gitweb的預設安裝路徑,我使用了find 命令,用來尋找gitweb所在的目錄

6 安裝gitosis時使用python3.3.0執行python setup.py install 報錯

問題產生

在安裝gitosis的時候,需要預先安裝工具包python-setuptools,安裝命令比較簡單

yum install python-setuptools

但是在clone了gitosis代碼,執行python安裝命令的時候報錯,錯誤提示如下:

ImportError: No module named setuptools

原因分析

網上摘要 Your setup.py file needs setuptools. Many of the Python packages use distutils for the distribution, but some use setuptools, a more complete package. Here is a question about the differences between them.Regarding Python 3.3, you should install distribute instead. It is a more recent package that works in the same way as setuptools (it‘s even called setuptools internally).連結地址:http://stackoverflow.com/questions/14426491/python-3-importerror-no-module-named-setuptools

centos預設的python版本是2.4.3,因為一次機會我升級了python的版本到3.3.0,這樣就出現了錯誤。

解決辦法

我的辦法是降低了python的版本,有興趣的同學可以嘗試安裝distribute包,看能不能解決這個問題

7 git push origin master 到github出錯

問題產生

本地項目添加了遠程倉庫,但是在推送代碼到遠程倉庫的時候,報無法串連到遠程伺服器

原因分析

github和本地代碼做推送和拉取時,需要用到ssh的金鑰組進行資料加解密,由於github上建立的項目沒有添加密鑰,所以本地倉庫串連不到遠程倉庫

解決辦法

在github上為該項目添加公開金鑰,推薦做法是不要單獨為每個項目添加公開金鑰,而是直接通過github帳號的ssh資訊維護開發機的ssh公開金鑰

Git 常見問題整理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.