常见错误整理:
【1】例如:gitpull origin2 master:dev显示如下的错误
error:Pull is not possible because you have unmerged files.。
解决办法:先git add ,然后gitcommit
【2】例如:分支合并时显示冲突,可以先将远程分支上的东西下载下来,在本地处理冲突过后,git add ,git commit,再gitmerge合并并提交到远程仓库。
【3】gitpush 远程库分支名称出现如下错误:
failedto push some refs to 'ssh://[email protected]:29418/Infoplatform.git'
hint:Updates were rejected because the remote contains work that you do
hint:not have locally. This is usually caused by another repository pushing
hint:to the same ref. You may want to first integrate the remote changes
hint:(e.g., 'git pull ...') before pushing again.
hint:See the 'Note about fast-forwards' in 'git push --help' for details.
应该先从远程仓库gitpull 远程库的名字master:dev ,然后在本地gitadd –all
,gitcommit –m “” ,再提交到远程的仓库中。
1、上传ssh时,服务器验证不过:
如果电脑上有ssh key,要将就有的备份并删除(直接删除文件即可),如果没有,输入以下命令:
1 $ ssh-keygen -trsa -C "邮件地址@youremail.com"
2 Generating public/private rsa key pair.
3 Enter file inwhich to save the key (/Users/your_user_directory/.ssh/id_rsa):<回车就好>
尤其注意第三行,应该直接回车,而不是输入自定义的文件名。然后将生成的id_rsa.pub的内容原封不动上传到git,之后测试命令:
1 ssh [email protected]
选择“yes”,输入用户名和密码,提示成功!
2、error: failed to push some refs to 'https://github.com/
git push代码时需要将远程仓库的文件拉下来(pull)然后push上去。
git的本地仓库由git维护的三棵树组成,第一棵是我的工作目录,它持有实际文件,第二棵是缓冲区(Index),保存临时改动,第三棵是head,指向最后提交后的结果。
1 git add
是将文件提交到缓存区,应该是“计划改动”,然后实际提交改动:
gitcommit -m "代码提交信息"
这时候改动已经提交到head,但是还没有到达远程仓库,调用:
1 git push originmaster
则是将改动提交到远程仓库,如果还没有克隆现有仓库,并欲将仓库连接到某个远程服务器,可以使用如下命令添加:
gitremote add origin
错误:
fatal: 'origin' does not appear to be a git repository
fatal: Could not read fromremote repository.
Please make sure you have thecorrect access rights
and the repository exists.
解决办法:
Elvis@ELVIS-PC /f/gitrepo/TestJedis (master)
$ git remote add origin git@gitserver:TestRedis.git
Elvis@ELVIS-PC /f/gitrepo/TestJedis(master)
$ git push origin master
ssh:gitserver: no address associated with name
fatal:Could not read from remote repository.
Please makesure you have the correct access rights
and therepository exists.
Elvis@ELVIS-PC /f/gitrepo/TestJedis(master)
$ git remote set-url [email protected]:afredlyj/TestRedis.git
Elvis@ELVIS-PC /f/gitrepo/TestJedis(master)
$ git push origin master
Enter passphrase for key'/c/Users/Elvis/.ssh/id_rsa':
Counting objects: 8, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (7/7),done.
Writing objects: 100% (7/7), 2.07KiB, done.
Total 7 (delta 2), reused 0 (delta 0)
To [email protected]:afredlyj/TestRedis.git
7bcfb1a..b02a2fe master ->master
Elvis@ELVIS-PC /f/gitrepo/TestJedis(master)