git subtree pull -P任何<回购> < REF>总是合并冲突 [英] git subtree pull -P whatever <repo> <ref> always merge conflict

查看:246
本文介绍了git subtree pull -P任何<回购> < REF>总是合并冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:即使没有变化,我每次尝试拉入子树时都会遇到合并冲突。

我在做什么



subtree-repo

 #进行一些更改

$ git commit -am'所做的更改'

$ git push origin master

main-repo



  $ git subtree add --prefix public / common {{subtree-repo}} master --squash 

#进行一些更改

$ git commit -am'所做的更改'

$ git subtree push --prefix public / common {{subtree-repo}} master

子树回购

  $ git pull origin master 

#进行一些更改

$ git commit -am'所做的更改'

$ git push origin master



main-repo

  $ git subtree pull --prefix public / common {{subtree-repo}} master --squash 

这是事情发生的地方。拉给我:

  remote:计数对象:5,完成。 
remote:压缩对象:100%(2/2),完成。
remote:合计3(delta 1),重用0(delta 0)
开箱对象:100%(3/3),完成。
从{{subtree-repo}}
* branch master - > FETCH_HEAD
a53e6fc..c078461 master - > {{subtree-repo}} / master
自动合并public / common / README.md
CONFLICT(内容):在public / common / README.md中合并冲突
自动合并失败;修复冲突,然后提交结果。

那么为什么当我没有做任何改变时我会遇到合并冲突?



我正在努力完成的任务:我有一个web项目和一个我在科尔多瓦建立的移动项目。因为它们都使用JavaScript,所以我想在两者之间分享几个组件和模型。我想把这些常见的东西放在它们两个之间的共享文件夹中,所以我不必复制粘贴。我研究了子模块和子树的优缺点,并决定使用子树。这是一个单人计划,但我想以正确的方式做事,以便扩展。



注意:If你有一个更好的方法来完成我想要做的事情的建议,那将是非常棒的: - )

不知道是什么原因导致了这个问题,但是我已经确定了一个更好的解决方案来实现我的目标:

  bower install git@bitbucket.org:username / my_repo.git --save 

所以我只会使用在回购之间共享资源。我没有意识到你可以使用一个git仓库url来构建一个bower组件。我说得很漂亮。不幸的是,这不允许我从我使用的回购库中进行上游更改,但至少我有一个超级简单的方法来执行此操作:)




更新



在Google+上发布了此方法 Rob Becker 提到你可以通过使用bower符号链接来简化它:



尝试添加bower链接以减少所有的复制。
您可以简单地将您的共享代码放在单独的回购站中,并将其设置为已有的凉亭组件。然后在bs-js-common中设置
$ bower link


链接。然后,在您的主项目中,您对bs-js-common有一个bower依赖关系,只需执行以下操作:
$ bower link bs-js-common



然后,您将从主项目bower_components / bs-js-common文件夹中的文件系统链接到实际项目回购所在的位置。这让您可以在两个地方看到实时更改。


The problem: I'm getting a merge conflict every time I try to pull into my subtree even when I have no changes.

What I'm doing:

In subtree-repo

# Make some changes

$ git commit -am 'Changes made'

$ git push origin master

In main-repo

$ git subtree add --prefix public/common {{subtree-repo}} master --squash

# Make some changes

$ git commit -am 'Changes made'

$ git subtree push --prefix public/common {{subtree-repo}} master

In subtree-repo

$ git pull origin master

# Make some changes

$ git commit -am 'Changes made'

$ git push origin master

In main-repo

$ git subtree pull --prefix public/common {{subtree-repo}} master --squash

And this is where things blow up. The pull gives me:

remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From {{subtree-repo}}
 * branch            master     -> FETCH_HEAD
   a53e6fc..c078461  master     -> {{subtree-repo}}/master
Auto-merging public/common/README.md
CONFLICT (content): Merge conflict in public/common/README.md
Automatic merge failed; fix conflicts and then commit the result.

So why am I getting a merge conflict when I haven't made any changes?

What I'm trying to accomplish: I have a web project and a mobile project I'm building on Cordova. Because they're both using JavaScript I have several components and models I want to share between the two. I'd like to put these common things in a shared folder between the two of them so I don't have to copy paste. I looked into the pros/cons of submodules and subtrees and decided on subtrees. This is a one-man project right now, but I would like to do things the right way so it can scale.

Note: If you have a suggestion for a better way to accomplish what I'm trying to do, that would be awesome :-)

解决方案

Not sure what's causing the problem, but I've determined a better solution for what I'm trying to accomplish:

bower install git@bitbucket.org:username/my_repo.git --save

So I'll just be using bower for sharing stuff between repos. I didn't realize you could use a git repository url for a bower component. Pretty sweet I say. Unfortunately this doesn't allow me to make upstream changes from the repo I'm using, but at least I have a super easy way to do it :)


Update

I posted this method on Google+ and Rob Becker mentioned that you could make it even simpler by using a bower symlink:

Try adding in "bower link" to reduce all that copying. You can simply have your shared code in separate repos and set up as bower components as you already have. Then do $ bower link in bs-js-common

This sets up the link. Then in your main project where you have a bower dependency on bs-js-common just do: $ bower link bs-js-common

You will then have a filesystem link from your main projects bower_components/bs-js-common folder to where the actual project repo lives. This lets you see live changes in both places.

这篇关于git subtree pull -P任何<回购> < REF>总是合并冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆