问题描述
缺少下面的内容:我想将提交消息推送到子树,但只将适用于该树的消息推送到子树。我如何做到这一点?
我有两个项目, Master
和从属
。 Slave
作为 Master
子树检出到 lib / slave
通过 git subtree merge --prefix = lib / slave --squash projects / slave
其中 projects / slave
是一个分支,从属
被签出到:
分支:
master
projects / slave→slave
现在我正在处理 master
分支,向作为这两个项目一部分的文件进行提交,一切都很顺利。现在我想将更改推回到 Slave
:
- git checkout slave
-
- git merge ??? master
如果我进行普通合并,我会为每个提交到master的提交,无论是否存在 lib / slave
被修改了。或者我可以做一个 - squash
并且只获得一次提交,但是我失去了日志信息。
那么如何获得适当的日志消息呢?例如如果我的 master
日志历史记录为:
-
- 仅修改从文件中的文件
- 更改仅用于修改主文件
- 修改主文件和从属文件中的文件
我想把它添加到从属
:
- 仅修改从属文件中的文件
- 修改主文件和从文件中的文件
- 修改主文件和从文件中的文件
对于你想要的行为,我想你必须从 Master
推送, t知道如何从 Slave
中引入子树更改。
推送更改:
(在Master中)
$ git subtree split --prefix = lib / slave -b split-branch
$ git push< ;裸机回购> split-branch:master
$ git branch -d split-branch
$ cd / path / to / Slave / working / copy
$ git pull#(现在在Slave中)
第一个命令根据目录创建一个新的子树,然后将其推送到另一个项目。
从理论上讲,您应该能够直接推送到工作副本,但在实践中,这对我不起作用。
The short of what's below: I want to push commit messages to a subtree, but only the messages that apply to that tree. How do I do this?
I have two projects, Master
and Slave
. Slave
is checked out as a subtree of Master
checked out to lib/slave
via git subtree merge --prefix=lib/slave --squash projects/slave
where projects/slave
is a branch that Slave
is checked out into:
Branches:
masterprojects/slave → slave
Now I'm working on my master
branch, making commits to files that are part of both projects, everything is going smoothly. Now I want to push changes back to Slave
:
- git checkout slave
- git merge ??? master
If I do a normal merge I get commits for every commit to master, whether or not any files in lib/slave
were modified. Or I can do a --squash
and only get a single commit, but I lose the log messages.
So how do I get the appropriate log messages? e.g. if my master
log history is:
- added images to master
- modified files in slave only
- more changes to master only
- modified files in master and slave
I'd want this added to Slave
:
- modified files in slave only
- modified files in master and slave
For the behavior you want, I think you'll have to push from Master
, I don't know of a way to pull subtree changes from Slave
.
To push changes:
(in Master)
$ git subtree split --prefix=lib/slave -b split-branch
$ git push <bare Slave repo> split-branch:master
$ git branch -d split-branch
$ cd /path/to/Slave/working/copy
$ git pull # (now in Slave)
The first command creates a new subtree based on the directory, which is then pushed to the other project.
In theory, you should be able to push directly to a working copy, but in practice that didn't work for me.
这篇关于git子树推回变回子树项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!