码迷,mamicode.com
首页 > 其他好文 > 详细

git问题解决

时间:2019-02-12 13:24:13      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:做了   size   com   ssi   err   log   rest   tor   问题   

1、如果系统中有一些配置文件在服务器上做了配置修改,然后后续开发又新添加一些配置项的时候,

在发布这个配置文件的时候,会发生代码冲突:

error: Your local changes to the following files would be overwritten by merge:
        protected/config/main.php
Please, commit your changes or stash them before you can merge.

如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:

  1. git stash 
  2. git pull 
  3. git stash pop

然后可以使用git diff -w +文件名 来确认代码自动合并的情况.

 

反过来,如果希望用代码库中的文件完全覆盖本地工作版本. 方法如下:

  1. git reset --hard 
  2. git pull

其中git reset是针对版本,如果想针对文件回退本地修改,使用:

   git checkout HEAD file/to/restore  

 

2、git .gitignore 文件 解决二进制文件冲突问题 

  .gitignore  主要是添加 忽略文件 。最近团队开发经常出现 

  UserInterfaceState.xcuserstate 冲突,打开发现是二进制文件 ,没法解决冲突。

  只好 rm -rf 之,次数多了真烦啦。

一劳永逸解决方案:

  1,找到 .gitignore 添加 UserInterfaceState.xcuserstate 不纳入版本管理

  2,移除git 已经跟踪的UserInterfaceState.xcuserstate  ,启用.gitignore 忽略对应文件

        1)、git rm --cached YourProjectFolderName.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate

         2)、git commit -m "Removed file that shouldn‘t be tracked"

         3)、git clean -f -d

 

3、git pull 报错

  error: Pulling is not possible because you have unmerged files.
  解决办法:
    1. git add -u
    2. git commit -m""
    3. git pull

  先将文件先存放到暂存区然后提交注释,再git pull不报错了
  这种报错一般是以为有冲突的文件,需要解决冲突或者合并文件,解决完或者合并之后需要重新提交,不限于pulling

git问题解决

标签:做了   size   com   ssi   err   log   rest   tor   问题   

原文地址:https://www.cnblogs.com/soft2018/p/10364472.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!