How to use the command `git missing` (with examples)

How to use the command `git missing` (with examples)

Git is a distributed version control system that allows multiple developers to collaborate on a project. The command git missing is a part of the git-extras package and it is used to show commits that are not shared between branches. This command is particularly useful when working on different branches and wanting to identify the unique commits in each branch.

Use case 1: Show commits which aren’t shared between the currently checked-out branch and another branch

Code:

git missing branch

Motivation: Suppose you are working on a feature branch feature-branch and you want to see the commits that are unique to your branch and have not been merged into another branch. In this case, you can use the git missing command to show the unique commits that are not shared between your branch and another branch.

Explanation: The argument branch in the command represents the name of the branch you want to compare with the currently checked-out branch. By running git missing branch, Git will display the commits that are not shared between the two branches.

Example output:

SHA   : 8840957756ea247907a211fe5f10e802ad5dafa4
Author: John Doe <johndoe@example.com>
Date  : 2022-01-01

    Add new feature

SHA   : 42a7c81a3237c7f013951c6c1de55c8746d1b9d3
Author: Jane Smith <janesmith@example.com>
Date  : 2022-01-02

    Fix issue #123

Use case 2: Show commits which aren’t shared between two branches

Code:

git missing branch_1 branch_2

Motivation: When working on a project with multiple branches, it is important to keep track of the commits that are unique to each branch. By using the git missing command with two branch names, you can easily see the commits that are not shared between the two branches.

Explanation: The arguments branch_1 and branch_2 in the command represent the names of the two branches you want to compare. Running git missing branch_1 branch_2 will display the commits that are not shared between the two branches.

Example output:

SHA   : 65e344ce00d93fb9e4b773e5f899f25b2599ea20
Author: John Doe <johndoe@example.com>
Date  : 2022-02-01

    Implement new feature

SHA   : f8b7c2c82ceda90a4cda12f5a8446a70b84e0fb9
Author: Jane Smith <janesmith@example.com>
Date  : 2022-02-02

    Fix bug in feature A

Conclusion:

The git missing command is a useful tool when working on multiple branches in a Git repository. By using this command, you can easily identify the unique commits in each branch and keep track of the changes made in different branches. Whether comparing the currently checked-out branch with another branch or two separate branches, the git missing command helps you see the commits that are not shared between them.

Related Posts

Using the xbps-query command (with examples)

Using the xbps-query command (with examples)

Introduction The xbps-query command is a utility that allows you to query package and repository information in XBPS, the package manager used by Void Linux.

Read More
How to use the command 'pihole' (with examples)

How to use the command 'pihole' (with examples)

The ‘pihole’ command is a terminal interface for the Pi-hole ad-blocking DNS server.

Read More
How to use the command 'systemd-ask-password' (with examples)

How to use the command 'systemd-ask-password' (with examples)

This article will explain how to use the ‘systemd-ask-password’ command with various use cases.

Read More