How to merge all files manually in Git?

后端 未结 7 2024
遥遥无期
遥遥无期 2021-01-30 01:30

I want to merge all files manually with meld or any other diff tool, how can I do this with Git?
When I run git mergetool it says no

7条回答
  •  离开以前
    2021-01-30 01:54

    For anyone who came here and is now wondering about the difference between @True's answer using git difftool and the other answers that use git merge, see Git mergetool vs difftool.

    In short, if you have git configured to use a modern diff.tool such as kdiff3, meld, or vimdiff, you'll be able to manually merge using that diff tool, and the command line can be simple:

    git difftool other_branch
    

    ...this will let you do a two-way manual merge between your current branch and other_branch (described as $LOCAL and $REMOTE in man git-config).

    The "correct" way the other answers discuss would be to instead configure git to use e.g. kdiff3 or vimdiff as your merge.tool, and use:

    git merge --no-commit --no-ff other_branch
    git mergetool
    

    ...this command can do an N-way manual merge between $BASE, $LOCAL, and $REMOTE, into $MERGED. See https://stackoverflow.com/a/2235841/1264797 for one example of how to configure git. You many not need to configure the mergetool.*.cmd entry at all if you use one of the tools git already knows about. (Meld can only show three panes, so if you use meld with the default settings, you'll not see $BASE.)

    Someone might jump in to correct me, but other than the N-way merge ability, the two methods appear to produce the same result. Neither difftool nor mergetool adds other_branch as a parent on the new commit, so in both cases, the merge isn't obvious in e.g. gitk and would have to be described (and noticed later) in the commit message.

提交回复
热议问题