git使用错误总结1

来源:互联网 发布:mac打不开word文档 编辑:程序博客网 时间:2024/06/04 19:55

常见错误整理:

1】例如:gitpull origin2 master:dev显示如下的错误

error:Pull is not possible because you have unmerged files.

解决办法:先git add,然后gitcommit

2】例如:分支合并时显示冲突,可以先将远程分支上的东西下载下来,在本地处理冲突过后,git addgit commit,再gitmerge合并并提交到远程仓库。

3gitpush远程库分支名称出现如下错误:

failedto push some refs to 'ssh://admin@112.74.57.234: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远程库的名字masterdev,然后在本地gitadd –all

,gitcommit –m “” ,再提交到远程的仓库中。

 

1、上传ssh时,服务器验证不过:

如果电脑上有ssh key,要将就有的备份并删除(直接删除文件即可),如果没有,输入以下命令:

1 $ ssh-keygen -trsa -C "邮件地址@youremail.com"

2 Generatingpublic/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 -Tgit@github.com

选择“yes”,输入用户名和密码,提示成功!

2、error: failed to push some refs to 'https://github.com/

git push代码时需要将远程仓库的文件拉下来(pull)然后push上去。

git的本地仓库由git维护的三棵树组成,第一棵是我的工作目录,它持有实际文件,第二棵是缓冲区(Index),保存临时改动,第三棵是head,指向最后提交后的结果。

1 git add<filename>

是将文件提交到缓存区,应该是“计划改动”,然后实际提交改动:

gitcommit -m "代码提交信息"

这时候改动已经提交到head,但是还没有到达远程仓库,调用:

1 git push originmaster

则是将改动提交到远程仓库,如果还没有克隆现有仓库,并欲将仓库连接到某个远程服务器,可以使用如下命令添加:

gitremote add origin <server>

错误:

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 origingit@github.com:afredlyj/TestRedis.git

Elvis@ELVIS-PC /f/gitrepo/TestJedis(master)

$ git push origin master

Enter passphrasefor key'/c/Users/Elvis/.ssh/id_rsa':

Counting objects:8, done.

Delta compression using up to2 threads.

Compressing objects:100% (7/7),done.

Writing objects:100% (7/7), 2.07KiB, done.

Total7 (delta 2), reused 0 (delta 0)

To git@github.com:afredlyj/TestRedis.git

  7bcfb1a..b02a2fe  master->master

Elvis@ELVIS-PC /f/gitrepo/TestJedis(master)