Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在git中的两个分支之间同步文件?_Git - Fatal编程技术网

如何在git中的两个分支之间同步文件?

如何在git中的两个分支之间同步文件?,git,Git,我已经完成了一个有许多分支机构的项目。我对两个分支特别感兴趣 1.8.x 2.2.x 我引入了一个新文件“newfile.source”,并对两个分支中存在的文件“existingfile.source”进行了更改。我想在两个分支之间同步我在newfile和existingfile中所做的更改 我在脑海中对此进行建模的方式如下: commit -- commit -- commit -- commit -- commit -- commit -- commit -- 2.2.x

我已经完成了一个有许多分支机构的项目。我对两个分支特别感兴趣

1.8.x
2.2.x
我引入了一个新文件“newfile.source”,并对两个分支中存在的文件“existingfile.source”进行了更改。我想在两个分支之间同步我在newfile和existingfile中所做的更改

我在脑海中对此进行建模的方式如下:

commit -- commit -- commit -- commit -- commit -- commit -- commit -- 2.2.x
                            \
                             -- commit -- 1.8.x
我希望有一个结构(分支,但只包括对existingfile和newfile的更改),可以对其进行更改并合并到1.8.x和2.2.x中:

nothing -- custom_changes -- nothing
然后做一些类似的事情:

git checkout 2.2.x
git merge custom_changes
git checkout 1.8.x
git merge custom_changes

只需将其提交到一个分支(像往常一样)。我更喜欢这里的新版本(2.2.x)。然后切换到旧分支(1.8.x)并使用