github - Git多分支公用类保持最新的办法
给我你的怀抱
给我你的怀抱 2017-05-02 09:28:19
0
2
597

例如有一个项目的master分支下有一个通用类A
我建立了一个新的分支dev进行开发(本地存在2个分支,1个是master,1个是dev),第二天master分支的类A代码更新了
而我如果拉取dev分支的话,A依然是旧版本的,如果拉取master分支的文件到本地dev的话,本地的master和dev就会显示合并了,请问要如何解决呢?

给我你的怀抱
给我你的怀抱

reply all(2)
迷茫

If you pull the files of the master branch to the local dev, the local master and dev will be merged. How to solve this problem?

Of course, don’t pull master to dev. This is essentially a fetch + merge operation, so this is inevitable.

There are actually many solutions. I prefer to use rebase, that is, first pull master, and then rebase master under the rebase,也就是先 pull master,然后在 dev 分支下 rebase master。这样做就等于把 dev 分支重新“落户”在 master 分支的最新节点(即:HEAD)上——当然,这个过程和 merge masterdev

branch. . Doing so is equivalent to re-"settling" the dev branch on the latest node (ie: HEAD) of the master branch - of course, this process is the same as merge master The same conflict resolution will occur (depending on the differences), but it will not merge the two branches.

In addition, this process should be done frequently (if master is updated frequently); at the same time, if master is the branch you use to deploy, it is best not to update it frequently, otherwise it will be very annoying to roll back if something goes wrong. 🎜
洪涛

You can checkout a file in other commits

git checkout origin/master -- 那个文件
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!