[英]How to merged only changed files from a past branch into the master in GIT?
Say I create a local branch named fix_5109 and work on it. 假设我创建了一个名为fix_5109的本地分支,并对其进行处理。 In the meantime the master branch changes and some files which I'm NOT editing are normally changed(eg. /controllers/AuthController.php). 在此期间,master分支发生了变化,而一些我不编辑的文件通常也发生了变化(例如/controllers/AuthController.php)。 If I push my changes to origin fix_5109 the lead developer wants to merge my branch into the master if all went alright. 如果我将更改推送到原点fix_5109上,那么如果一切顺利,首席开发人员想将我的分支合并到master中。 My branch contains the old AuthController.php from an older commit behind master's newer. 我的分支包含来自master的较新版本之后的较旧提交的旧AuthController.php。 Will the file in the master branch be overwritten by my version of the file or would it reject my version of that file and update only the files I've edited in the branch I've pushed? master分支中的文件会被我的文件版本覆盖还是会拒绝该文件的版本并仅更新我在推送的分支中编辑的文件?
git
functions in a way where if a commit is already applied, it won't be applied again (Uniqueness by commit hash). git
作用方式是,如果已经应用了提交,则不会再次应用(通过提交哈希唯一性)。 So for your case, assuming you had diverged from master at some point in time when the changes to AuthController.php had already been made, then you don't have to worry. 因此,对于您的情况,假设您已经在对AuthController.php进行更改的某个时间与主服务器背道而驰,那么您不必担心。 Since, git would not replay a existing commit. 由于git不会重播现有的提交。
So even if your lead merges changes from your branch. 因此,即使您的潜在客户合并,分支机构也会发生变化。 He will basically have the latest code. 他基本上将拥有最新的代码。 ie) what ever change was last made (without diverging). 即)最后所做的更改(无差异)。 If the changes were made separately, then git would try to resolve the commits and apply them one after the other. 如果更改是分开进行的,则git会尝试解析提交,然后一次又一次地应用它们。 In this case, if there is a conflict then you would need to handle it explicitly. 在这种情况下,如果存在冲突,则需要显式处理。
git checkout master
git pull origin master
git checkout fix_5109
git rebase master
Basically rebasing your branch with the current state of master will take care of the issue you are concerned about. 从根本上以分支机构的当前状态重新分支您的分支机构将解决您担心的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.