Perforce p4 交换等价于 git

Perforce p4 interchanges equivalent in git

我正在寻找 git 中的 p4 interchanges 等价物。是否有任何 option/flag 用于查找一个分支中尚未 integrated/merged 到另一个分支的更改。

我正在寻找这个选项来跟踪在我的功能分支中所做的更改是否尚未合并到主分支中,然后我才能剪切发布分支。

使用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>

其中 <upstream><head> 指的是 git 分支
<limit> 指的是 git 存储库历史记录中的一次提交。


topic 分支由三个提交组成的情况下,
并且维护者将其中两个应用于 origin/master,情况可能如下所示:

$ 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

现在 git-cherry 将显示尚未应用到 origin/master 的内容的简明摘要:

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

在这里,我们看到提交 AC(标有 -)已经被挑选到 origin/master,而提交 B(标有 +)尚未合并到 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.

参考:man page of git cherry.