git使用时的各种问题

1. Pull is not possible because you have unmerged files.

$ git pull

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'

应该是因为local文件冲突了

解决方法:
    1.pull会使用git merge导致冲突,需要将冲突的文件resolve掉 git add -u, git commit之后才能成功pull.
    2.如果想放弃本地的文件修改,可以使用git reset --hard FETCH_HEAD,FETCH_HEAD表示上一次成功git pull之后形成的commit点。然后git pull.

注意:
    git merge会形成MERGE-HEAD(FETCH-HEAD)git push会形成HEAD这样的引用。HEAD代表本地最近成功push后形成的引用。
    
有时候会莫名其妙地出现这种状况,而且Untracked files 还特别多(实际上自己可能只改了一两个文件),所以只好先保存好自己确定做出的local的修改,然后用git reset --hard FETCH_HEAD回到上次成功pull之后的点,然后再pull就没有问题了

 2.You are not currently on a branch.

症状:有一次pull的时候又出现冲突,这回用“git reset --hard FETCH_HEAD”方法都不行了,出现:

$ git pull

You are not currently on a branch, so I cannot use any
'branch.<branchname>.merge' in your configuration file.
Please specify which remote branch you want to use on the command
line and try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

解决方法:
    1.git checkout -b temp
    2.git checkout master
    即可恢复到master repository的状态,然后就可以pull了

 3.failed to push some refs to 'xxx(远程库)'

    主要是因为远程仓库有README.md
    1.曾连接过其余的仓库git地址的,需要将C:\Users\Administrator\.git-credentials.lock 删除
    2.执行git pull –-rebase origin master  (pull=fetch+merge)

 4.Please make sure you have the correct access rights and the repository exists.

执行git push origin master时 抛出 Please make sure you have the correct access rights and the repository exists.
    1.首先我得重新在git设置一下身份的名字和邮箱(因为当初都忘了设置啥了,因为遇到坑了)进入到需要提交的文件夹底下(因为直接打开git Bash,在没有路径的情况下,根本没!法!改!刚使用git时遇到的坑。。。) 
        git config --global user.name "zhaochunxue"
        git config --global user.email "1564819304@qq.com"
    2.删除.ssh文件夹(直接搜索该文件夹)下的known_hosts(手动删除即可,不需要git)
        在C:\Users\Administrator\.ssh\known_hosts
    3.git输入命令
        $ ssh-keygen -t rsa -C "1564819304@qq.com"(请填你设置的邮箱地址)
    4.复制id_rsa.pub里边的内容到http://10.19.157.170:3000/user/settings/ssh
    5.在git中输入命令:
        ssh -T git@github.com
    6.完成(git push origin master成功)
    泪流满面啊
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值