Raghuveer
Raghuveer

Reputation: 1493

Perforce p4 interchanges equivalent in git

I am looking for p4 interchanges equivalent in git. Is there any option/flag for finding the changes which are in one branch yet to be integrated/merged to another branch.

I am looking for this option to track if changes done in my feature branch are yet to be merged into master branch before I can cut a release branch.

Upvotes: 2

Views: 387

Answers (1)

TheCodeArtist
TheCodeArtist

Reputation: 22487

How about using git cherry?

git cherry [-v] [<upstream> [<head> [<limit>]]]

  • outputs the SHA1 of every commit between <limit> and <head>,
  • and prefixes a - to commits in the list that have an equivalent in <upstream>
  • and prefixes a + to commits in the list that do not have an equivalent in <upstream>

where <upstream> and <head> refer to git branches
and <limit> refers to a commit in the history of the git repository.


In a situation where a topic branch consisted of three commits,
and the maintainer applied two of them to origin/master, the situation might look like:

$ git log --graph --oneline --decorate --boundary origin/master...topic
* 7654321 (origin/master) upstream tip commit
|
* cccc111 cherry-pick of C
* aaaa111 cherry-pick of A
|
| * cccc000 (topic) commit C
| * bbbb000 commit B
| * aaaa000 commit A
|/
o 1234567 branch point

Now git-cherry will show a concise summary of what is yet to be applied to origin/master:

$ git cherry origin/master topic
- cccc000... commit C
+ bbbb000... commit B
- aaaa000... commit A

Here, we see that the commits A and C (marked with a -) are already cherry-picked into origin/master, while the commit B (marked with a +) is yet to be merged into origin/master.

When we have 2 local branches X and Y to be compared;

To ask the question:
Are there any commits in branch X that are NOT yet in branch Y?

we would say git cherry branchY branchX and look for any commits listed with a + before them.

Reference: man page of git cherry.

Upvotes: 2

Related Questions