For example, there is a general class A under the master branch of a project
I created a new branch dev for development (there are 2 branches locally, 1 is master and 1 is dev). The next day The class A code of the master branch has been updated
and if I pull the dev branch, A is still the old version. If I pull the files of the master branch to local dev, the local master and dev will be merged. How to solve this problem?
迷茫2017-05-02 09:30:19
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 master
dev
dev
branch on the latest node (ie: HEAD) of the master
branch - of course, this process is the same as merge master< /code> 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. 🎜reply0
PHP中文网2017-05-02 09:30:19
You can checkout a file in other commits
git checkout origin/master -- 那个文件