學習git遇到的一些簡單錯誤


From:http://stackoverflow.com/questions/7574459/prompted-for-password-on-git-pull-origin-branch

 

[root@localhost test]# git pull
admin@127.0.0.1's password:

 

 

If you're being prompted for a password, and not your SSH key's passphrase, then you're not using the SSH URL. HTTPS asks for user/pass auth, SSH uses key/passphrase. Check your remote's URL withgit remote -v, and if you need to fix it use git remote set-url.

git push origin HEAD:refs/for/master命令,出現以下錯誤提示:

To ssh://user2@gerrit.example.com:29418/HelloWorld.git
 ! [remote rejected] master -> refs/for/master (missing Change-Id in commit message footer)

這是因為gerrit中對應的版本庫中,設置了以下功能:

解決方案:
1、將側向設置通過admin賬戶改為false
2、 下載hook腳本到本地版本庫下的.git/hooks目錄下:
scp -p 29418 user2@gerrit.example.com:hooks/commit-msg <local path to your git>/.git/hooks/

這里需要注意下載的commit-msg文件需要放在project所在目錄的.git/hooks下。之前試了多次都不行,一看,原來是直接下載到了project目錄下。

下載到.git/hooks目錄下后,需要執行:

git commit --amend -m 'comment'

對之前的commit進行修改,生成chang-id。

通過查看本次提交,可以發現:

[root@admin test]# git show 6d02aa6
commit 6d02aa69e0ced163584d5197f302ae3cd1d5e45b
Author: admin <admin@test.com.cn>
Date:   Mon Dec 15 09:05:18 2014 +0800

    Add something to repo.
    
    Change-Id: I6c425c3a78cbe40cedb844947fcfb69b65f95458

本次提交的提交說明中出現了Chang-Id,然后執行git push即可成功推送代碼到遠程版本庫。

 

之后,當提交代碼時,執行git commit會自動生成Change-Id。


免責聲明!

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



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