学习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。

原文地址:https://www.cnblogs.com/xiaoerlang/p/3512432.html