Can I perform ‘merge’ that updates only existing files in current branch?
For example, I have branch1: /file1, /x/file2, /file3. And branch2: /file1, /x/file2, /z/file4. I want to update files file1 and file2 in second branch with files from first.
As a solution I see creating separate commits in branch1 for that files, and than use chery-pick in second branch.
UPD:
Thanks to @fge, I’ve founded that solution (not so simple as I had expected):
git co branch2
git co branch1 -- ./
git reset ./
git ci -a
git clean -f
You can proceed as such while on
branch2:Then
git addthe modified files and commit the result.If you want to have the commit message of branch1 as well, you could commit with
git commit -c branch1.Note that
branch1really is a refspec. A branch in git is nothing but a commit, but as a commit has links to its parent(s), it is, in effect, a “branch”.