git个人记录

/*生成ssh公钥:
ssh-keygen -t rsa -C "[email protected]"  
如何查看id_rsa.pub公钥:
cat id_rsa.pub
*/


server:
1.新建远程仓库并初始化
2.sudo chmod -R 777 仓库
3.sudo chown -R git:git 仓库
4.git config receive.denyCurrentBranch ignore(好像是每次关联仓库时都要执行)


client:
1.新建本地仓库并初始化
2.git remote add origin [email protected]:/home/git/hmi.git
如果提示origin已存在,则
git remote rm origin后再执行一遍。
3.git push -u origin master
4.git push --set-upstream origin master






问题记录:
1.现象:
$ git push -u origin master
[email protected]'s password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 210 bytes | 210.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To merrill.net.cn:/home/git/hmi.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '[email protected]:/home/git/hmi.git'
原因/解决方法:
git仓库端(ubuntu)执行git config receive.denyCurrentBranch ignore
参考:http://blog.csdn.net/chaihuasong/article/details/17398835




2.现象:
$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to '[email protected]:/home/git/hmi.git'
原因/解决方法:
本地仓库或远程仓库不能为空,在本地仓库新建个README.md文件,并add、commit后重试即可。





































猜你喜欢

转载自blog.csdn.net/yanlutian/article/details/80653761