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?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(5)
我想大声告诉你

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'

The above is the whole process

仅有的幸福

Switch to the master branch, then merge dev and push it

phpcn_u1582

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template