解决git pull时出现的几个问题

来源:互联网 发布:mac解压带密码的rar 编辑:程序博客网 时间:2024/05/01 20:13
解决git pull时出现的几个问题

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

今天在执行git pull时出现:

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

解决方法:
执行git checkout -f,然后再执行git pull重新checkout

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

再执行git pull时就可以了:

  1. [root@gitserver /data/work/www/rest/lib/Business/Inventory]# git pull  
  2. Enter passphrase for key '/root/.ssh/id_rsa':  
  3. Updating 70e8b93..a0f1a6c  
  4. Fast-forward 
  5.  rest/lib/Business/Inventory/ProductStatus.php |    1 +  
  6.  1 files changed, 1 insertions(+), 0 deletions(-)  
  7.  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之后的提示:

  1. $ git pull  
  2. Password:  
  3. You asked me to pull without telling me which branch you  
  4. want to merge withand 'branch.master.merge' in 
  5. your configuration file does not tell me, either. Please  
  6. specify which branch you want to use on the command line and 
  7. try again (e.g. 'git pull <repository> <refspec>').  
  8. See git-pull(1) for details.  
  9.    
  10. If you often merge with the same branch, you may want to 
  11. use something like the following in your configuration file:  
  12.    
  13. [branch "master"]  
  14.  remote = <nickname>  
  15.  merge = <remote-ref>  
  16.    
  17. [remote "<nickname>"]  
  18.  url = <url>  
  19.  fetch = <refspec>  
  20.    
  21. See git-config(1) for details. 

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

  1. git remote add -f origin git@192.168.21.44:rest.git  
  2. git config branch.master.remote origin  
  3. git config branch.master.merge refs/heads/master 
0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 开拼多多找不到低价货源怎么办 要是校花追你该怎么办 苏宁自提逾期怎么办 天猫超市有问题怎么办 买的东西质量有问题怎么办 淘宝优惠额度大做不了怎么办 淘宝天猫拒绝退货退款怎么办 u盘变成活动分区怎么办 学生上课纪律差家长老师怎么办 老师管纪律学生打老师怎么办? 淘宝店铺层级排名下降怎么办 网购不支持该地区销售怎么办 分销公司佣金不给业务员怎么办 淘宝买家账号违规了怎么办 王者荣耀打野被队友抢野怎么办 艾肯材料换错了怎么办 淘宝直播粉丝5万怎么办 淘宝直播刚开始好难怎么办 分期乐账号忘记了怎么办 外链多了影响网站排名怎么办 自粘墙纸有气泡怎么办 贴壁纸阴角不力怎么办 自贴墙纸有气泡怎么办 壁纸贴的有起泡怎么办 pos机连接主机失败怎么办 无线pos机连接主机失败怎么办 水墨晕染模板用不了怎么办 申请入驻饿了么失败怎么办 天猫流量大淘宝怎么办 拼多多商家不退款怎么办 苹果手机开流量显示e怎么办 苹果手机有服务流量打不开怎么办 苹果七plus流量打不开怎么办 苹果手机突然打不开流量怎么办 天猫商家迟迟不发货怎么办 苹果7开不开机了怎么办 苹果机黑屏了开不起来怎么办 美团收银机连不上网怎么办 6s换电池后黑屏怎么办 苹果上的软件打不开也删不掉怎么办 苹果手机打开软件打不开怎么办