`

git pull遇到的问题以及解决方式!

    博客分类:
  • git
 
阅读更多

第1个问题: 解决GIT代码仓库不同步

今天在执行git pull时出现:

 

[root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull  
Enter passphrase for key '/root/.ssh/id_rsa':  
Updating 70e8b93..a0f1a6c  
error: Your local changes to the following files would be overwritten by merge:  
        rest/lib/Business/Inventory/ProductStatus.php  
Please, commit your changes or stash them before you can merge.  
Aborting

 解决方法:

 

执行git checkout -f,然后再执行git pull重新checkout

 

[root@gitserver /data/work/www/rest/lib/Business/Inventory]# git checkout -f  
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded. 

 再执行git pull时就可以了:

[root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull  
Enter passphrase for key '/root/.ssh/id_rsa':  
Updating 70e8b93..a0f1a6c  
Fast-forward 
 rest/lib/Business/Inventory/ProductStatus.php |    1 +  
 1 files changed, 1 insertions(+), 0 deletions(-)  
 mode change 100644 => 100755 rest/lib/Business/Inventory/ProductStatus.php 

 

第2个问题: git pull的默认地址问题.

1.git处于master这个branch下时,默认的remote就是origin;
2.当在master这个brach下使用指定remote和merge的git pull时,使用默认的remote和merge。
 
但是对于自己建的项目,并用push到远程服务器上,并没有这块内容,需要自己配置。
如果直接运行git pull,会得到如此结果:

#当执行git pull之后的提示:

$ git pull  
Password:  
You asked me to pull without telling me which branch you  
want to merge with, and 'branch.master.merge' in 
your configuration file does not tell me, either. Please  
specify which branch you want to use on the command line and 
try again (e.g. 'git pull <repository> <refspec>').  
See git-pull(1) for details.  
   
If you often merge with the same branch, you may want to 
use something like the following in your configuration file:  
   
[branch "master"]  
 remote = <nickname>  
 merge = <remote-ref>  
   
[remote "<nickname>"]  
 url = <url>  
 fetch = <refspec>  
   
See git-config(1) for details. 

 #解决方法, 通过git config进行如下配置.

git remote add -f origin git@192.168.21.44:rest.git  
git config branch.master.remote origin  
git config branch.master.merge refs/heads/master 

 

 

 

分享到:
评论

相关推荐

    Git基本操作和问题汇总

    资源主要包括对Git基本操作的汇总,以及在使用Git的过程中遇到的问题,例如:git如何创建并推送到远程分支,git pull拉取代码时,冲突的解决办法等。

    Git基础之合并解决冲突

    最初自动化代码是有一个人搭建起来,后来有3个测试同事加入编写测试代码,最先遇到的问题就是多人之间的协同问题,简单的gitpull和gitpush变得不听话起来,每次一提交代码就有代码冲突出现。下面看看我是如何解决的...

    第一次使用Git上传本地项目到github上.wps

    第一次使用Git上传本地项目到github上 操作步骤(本人使用的gitee),有百度经验来的总结和自己在实践中总结的,基本上文档里面会把遇到的所有问题解决

    error: failed to push some refs to &#039;https://gitee.com/xiao-long

    学习git的基本操作时,遇到问题error: failed to push some refs to 'https://gitee.com/xiao-longlong/git-test.git' ...解决办法:先执行git pull --rebase origin master 然后执行git push origin master即可

    start-here-guides:让Git从开源世界开始

    在进行任何更改之前, 以避免合并冲突: git remote add upstream https://github.com/zero-to-mastery/start-here-guidelines.gitgit pull upstream master 如果遇到合并冲突,则必须解决冲突。 在线上有很多指南...

    github pull最新代码实现方法

    github现在已经经常用了,但是经常遇到下面的问题 比如:从一个项目A中fork了一个分支B,并且在分支B有了改动。过了几天后,项目A中的代码应该会有很多人提交修改了,现在想将最新的代码pull到分支B。请问如何做呢?...

    ChatSystem:一个简单但不错的聊天系统

    要使用在线更改更新计算机上的存储库,您只需启动 - 从存储库 - git pull INSA 学生注意:克隆代理后面的存储库时您可能会遇到一些问题。 要解决这个问题,请使用此命令export ...

    adminli

    更新代表有新的内容增加,您可以更新也可以继续使用之前的版本,不影响当前使用,除非说明需要重新部署修复代表有错误已经修复完毕需要您执行相关命令解决相应的问题,如有特殊命令需要执行会在维基首页发布通知代表...

    hacktoberfest2020-algorithms

    Hacktoberfest2020-算法 您可以用这个仓库做什么? 您可以为自己喜欢的编程语言(如果尚不存在)添加一个新文件夹,然后开始向... 如果遇到合并冲突,则必须解决冲突。 在线上有很多指南,也可以通过尝试。 现在进入

    testing-toyproblems

    测试玩具问题我的解决方案,用于测试浏览器用Javascript编写的玩具问题和算法。要求该套件需要bower,npm和node。安装要么分叉此存储库,要么直接下载最新版本。 打开一个终端窗口,然后进入testing-toyproblems目录...

    sau.github.io:sau.github.io

    因为主题在不断的更新,所以你可能会遇到冲突,需要手动解决。在更新之前,建议备份下当前的配置。 特性 特性概览: 支持 About 页面 支持 5 款代码高亮主题 支持 Google / 百度统计 支持 Google Webmaster tools ...

    Gookie:轻量级、可配置的 GitHub webhook 服务器

    它旨在解决我们在遇到的一两个问题,例如在终端中提到 ping 事件发生并在 git pull/我们的部署脚本期间显示错误。 要将 Gookie 作为服务/守护程序运行,我建议您查看。 这是一个非常时尚的 npm 包,用于停止/启动/...

    leetcode下载-kaggle-book:kaggle题解

    阅读过程中遇到任何问题,可以以issue的形式提出来,这样可以帮助其他读者来发现、解决这个问题,也可以直接提pull request,贡献您的智慧。 贡献者 github 按字典序 如何贡献 1.登录github,并且fork这个项目 2.从...

    javaee登陆页面源码-trade:https://github.com/sun0x00/RedTorch.git

    GIL带来的性能问题难以突破,不能有效使用多核CPU,利用Java能比较好的解决这一问题,在多账户多合约方面有一定便利。 作为便捷的动态语言,Python在数据分析等领域有着天生的优势,但在数据类型控制、重构方面会...

Global site tag (gtag.js) - Google Analytics