git - How to update the same file in different branches?
黄舟2017-05-02 09:23:24
0
5
721
For example, branch master and branch dev have a file file.ext at the same time. I updated (commit & push) this file on branch dev. How can I update the file on branch master when my colleagues update?
The solution I gave is not automatic and requires manual operation. It should not be possible to automatically update a single file 1: First switch to the master branch:
git checkout master
2: Take out the file.ext file on the dev branch
git checkout dev -- file.ext
3: Then submit file.ext to the master branch
git add file.ext
git commit -m 'update file.ext from dev'
If this submission only contains this one required file, then the colleague can just use master to pull origin dev
If there are multiple commits on origin, and the colleague’s master only needs one of them, then the colleague will first pull origin dev on dev, and then return to master to cherrypick the commit(s) needed on dev
If this target file is mixed in a certain submission (that is, there is more than one change in the submission, but the colleague’s master only needs this one file), then just like @brucemj said, manually checkout
There is a way. First push the content you want to update. Then switch the branch and then right-click replace width and select branch, tag, or reference to select the branch content you just submitted. It will be ok
The solution I gave is not automatic and requires manual operation. It should not be possible to automatically update a single file
1: First switch to the master branch:
2: Take out the file.ext file on the dev branch
3: Then submit file.ext to the master branch
The above is the whole process
Switch to the master branch, then merge dev and push it
If this submission only contains this one required file, then the colleague can just use master to pull origin dev
If there are multiple commits on origin, and the colleague’s master only needs one of them, then the colleague will first pull origin dev on dev, and then return to master to cherrypick the commit(s) needed on dev
If this target file is mixed in a certain submission (that is, there is more than one change in the submission, but the colleague’s master only needs this one file), then just like @brucemj said, manually checkout
There is a way. First push the content you want to update. Then switch the branch and then right-click replace width and select branch, tag, or reference to select the branch content you just submitted. It will be ok
This is the eclipse .git plug-in
git checkout master
git cherry-pick commit-id