轉的git

來源:互聯網
上載者:User

標籤:rsa   允許   存在   2.3   關鍵字   not   dd命令   選項   log   

原文連結:http://blog.csdn.NET/dengjianqiang2011/article/details/9260435

 

 如果輸入$ Git remote add origin [email protected]:djqiang(github帳號名)/gitdemo(項目名).git 

    提示出錯資訊:fatal: remote origin already exists.

    解決辦法如下:

    1、先輸入$ git remote rm origin

    2、再輸入$ git remote add origin [email protected]:djqiang/gitdemo.git 就不會報錯了!

    3、如果輸入$ git remote rm origin 還是報錯的話,error: Could not remove config section ‘remote.origin‘. 我們需要修改gitconfig檔案的內容

    4、找到你的github的安裝路徑,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc

    5、找到一個名為gitconfig的檔案,開啟它把裡面的[remote "origin"]那一行刪掉就好了!

 

 

    如果輸入$ ssh -T [email protected]
    出現錯誤提示:Permission denied (publickey).因為新產生的key不能加入ssh就會導致串連不上github。

    解決辦法如下:

    1、先輸入$ ssh-agent,再輸入$ ssh-add ~/.ssh/id_key,這樣就可以了。

    2、如果還是不行的話,輸入ssh-add ~/.ssh/id_key 命令後出現報錯Could not open a connection to your authentication agent.解決方案是key用Git Gui的ssh工具產生,這樣產生的時候key就直接儲存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令列來做。

    3、最好檢查一下在你複製id_rsa.pub檔案的內容時有沒有產生多餘的空格或空行,有些編輯器會幫你添加這些的。

 

 

    如果輸入$ git push origin master

    提示出錯資訊:error:failed to push som refs to .......

    解決辦法如下:

    1、先輸入$ git pull origin master //先把遠程伺服器github上面的檔案拉下來

    2、再輸入$ git push origin master

    3、如果出現報錯 fatal: Couldn‘t find remote ref master或者fatal: ‘origin‘ does not appear to be a git repository以及fatal: Could not read from remote repository.

    4、則需要重新輸入$ git remote add origin[email protected]:djqiang/gitdemo.git

 

 

    使用git在本地建立一個項目的過程

    $ makdir ~/hello-world    //建立一個項目hello-world
    $ cd ~/hello-world       //開啟這個項目
    $ git init             //初始化 
    $ touch README
    $ git add README        //更新README檔案
    $ git commit -m ‘first commit‘     //提交更新,並注釋資訊“first commit”
    $ git remote add origin [email protected]:defnngj/hello-world.git     //串連遠程github項目  
    $ git push -u origin master     //將本地項目更新到github項目上去

 

   

    gitconfig設定檔

         Git有一個工具被稱為git config,它允許你獲得和設定組態變數;這些變數可以控制Git的外觀和操作的各個方面。這些變數可以被儲存在三個不同的位置: 
         1./etc/gitconfig 檔案:包含了適用於系統所有使用者和所有庫的值。如果你傳遞參數選項’--system’ 給 git config,它將明確的讀和寫這個檔案。 
         2.~/.gitconfig 檔案 :具體到你的使用者。你可以通過傳遞--global 選項使Git 讀或寫這個特定的檔案。
         3.位於git目錄的config檔案 (也就是 .git/config) :無論你當前在用的庫是什麼,特定指向該單一的庫。每個層級重寫前一個層級的值。因此,在.git/config中的值覆蓋了在/etc/gitconfig中的同一個值。
        在Windows系統中,Git在$HOME目錄中尋找.gitconfig檔案(對大多數人來說,位於C:\Documents and Settings\$USER下)。它也會尋找/etc/gitconfig,儘管它是相對於Msys 根目錄的。這可能是你在Windows中運行安裝程式時決定安裝Git的任何地方。

 

        配置相關資訊:

        2.1 當你安裝Git後首先要做的事情是設定你的使用者名稱稱和e-mail地址。這是非常重要的,因為每次Git提交都會使用該資訊。它被永遠的嵌入到了你的提交中:

  $ git config --global user.name "John Doe"

  $ git config --global user.email [email protected]

 

       2.2    你的編輯器(Your Editor)

  現在,你的標識已經設定,你可以配置你的預設文字編輯器,Git在需要你輸入一些訊息時會使用該文字編輯器。預設情況下,Git使用你的系統的預設編輯器,這通常可能是vi 或者 vim。如果你想使用一個不同的文字編輯器,例如Emacs,你可以做如下操作:

  $ git config --global core.editor emacs

 

      2.3 檢查你的設定(Checking Your Settings)

  如果你想檢查你的設定,你可以使用 git config --list 命令來列出Git可以在該處找到的所有的設定:

  $ git config --list

      你也可以查看Git認為的一個特定的關鍵字目前的值,使用如下命令 git config {key}:

  $ git config user.name

 

      2.4 擷取協助(Getting help)

  如果當你在使用Git時需要協助,有三種方法可以獲得任何git命令的手冊頁(manpage)協助資訊:

  $ git help <verb>

  $ git <verb> --help

  $ man git-<verb>

  例如,你可以運行如下命令擷取對config命令的手冊頁協助:

  $ git help config

轉的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.