简体   繁体   English

列出自创建分支以来master中的更改

[英]List changes in master since a branch was created

A branch, called mil-1 (for milestone) was created from master some time ago. 不久前从master创建了一个名为mil-1 (代表里程碑)的分支。 There have been changes to master since this branch was created. 自创建该分支以来,master发生了更改。 I need to review them and merge some of them into the milestone branch. 我需要对其进行审查,并将其中一些合并到里程碑分支中。

After running git fetch --all , git log refs/heads/master lists the changes in master; 运行git fetch --allgit log refs/heads/master列出git log refs/heads/master中的更改; and I know how to restrict them to a certain number of commits: 而且我知道如何将它们限制为一定数量的提交:

$ git log -1 origin/master
commit 5401cc7edf382183537a011632c422a491faea5b
Author: ********
Date:   Wed May 28 18:29:59 2014 +0530

But how do I restrict the output to only to commits done after the mil-1 branch was created? 但是,如何将输出限制为仅创建mil-1分支之后完成的提交?

Assuming that mil-1 hasn't been updated with the new commits made to master , then this is done using a simple commit range: 假设尚未使用对master的新提交来更新mil-1 ,那么可以使用简单的提交范围来完成此操作:

git log mil-1..origin/master

will show you all commits that exist in the origin/master that don't yet exist in mil-1 . 将向您显示在mil-1还不存在的所有在origin/master中的提交。

See also Pro Git § 6.1 Git Tools - Revision Selection: Commit Ranges . 另请参阅Pro Git§6.1 Git工具-版本选择:提交范围

But how do I restrict the output to only to commits done after the mil-1 branch was created? 但是,如何将输出限制为仅创建mil-1分支之后完成的提交?

First you can use git merge-base to find the most recent commit the two branches have in common (which in your case is probably the commit that the branch was created from): 首先,您可以使用git merge-base查找两个分支共同拥有的最新提交(在您的情况下,可能是创建分支的提交):

mergebase=$( git merge-base master mil-1 )

Then you can list all commits on the master branch since then: 然后,您可以在此之后在master分支上列出所有提交:

git log $mergebase..master

Alternatively, you get the same result just asking for all commits between mil-1..master , which tells you all the commits which are in the history of master but not in the history of mil-1 或者,您只需要在mil-1..master之间进行所有提交即可得到相同的结果,它告诉您在master历史记录中但不在mil-1历史记录中的所有提交

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 git - 自创建以来对分支的更改? - git - changes to branch since created? 自分支首次创建以来,如何保持Git中的合并不会覆盖我所有主服务器的更改? - How do I keep merge in Git from overwriting all my master's changes since the branch was first created? 获取自特定日期时间以来分支中的更改列表 - Get list of changes in branch since certain datetime 是否可以从 master 创建的分支中获取更改作为本地更改返回到 master? - Is it possible to get changes from a branch created from master back to master as local changes? git自创建以来一个分支 - git rebase a branch since it was created 如何获取以前合并到主分支的整个更改列表? - How to get whole list of changes for a previously-merged-to-master branch? 如果我将推送新创建的分支,主分支是否会发生变化(请参阅详细信息)? - Will master branch have changes if I will push my new created branch(see details)? 查看分支是直接在 Visual Studio 2019/2022(或 Rider)中创建后的更改 - See changes since branch was created directly in Visual Studio 2019/2022 (or Rider) 将主服务器中的更改添加到远程分支 - Add changes in master to remote branch 一个分支中的更改显示在master中 - Changes in one branch appear in master
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM