Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See what would be merged in one git command?

Tags:

git

merge

Currently, before merging a branch, I use the following commands to see what changes will be merged:

base=$(git merge-base other HEAD)
git diff $base other

Is there a single git command to achieve this?

Regards, Jochen

like image 627
Jochen Avatar asked Nov 10 '10 15:11

Jochen


People also ask

How do I see merge conflicts in git?

General tools. The status command is in frequent use when a working with Git and during a merge it will help identify conflicted files. Passing the --merge argument to the git log command will produce a log with a list of commits that conflict between the merging branches.

How do I know which branches are merged?

You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.

How do I know if a commit is merged?

You just need to check the length of the `parents`. If there are two or more commits, it's a merge commit, otherwise it's a regular commit.

Which git command is used to display merge history?

The most basic and powerful tool to do this is the git log command. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order — that is, the most recent commits show up first.


2 Answers

git diff ...other
like image 146
Sven Marnach Avatar answered Sep 24 '22 05:09

Sven Marnach


Note: the question "How can I preview a merge in git?" does mention the context of seeing what would be merged when fetching:

[alias]
    # fetch and show what would be merged (use option "-p" to see patch)
    incoming = "!git remote update -p; git log ..@{u}"

With:

  • "git incoming" to show a lot of changes, or
  • "git incoming -p" to show the patch (i.e., the "diff"),
  • "git incoming --pretty=oneline", for a terse summary, etc

You can find more elaborate scripts in this:

  • GitHub example:
  • gitpastiche
like image 43
VonC Avatar answered Sep 23 '22 05:09

VonC