[英]git - changes to branch since created?
I'm always asking myself a set of questions about branches i've created that i've yet to determine how to accomplish: 我总是问自己一些关于我创建的分支的问题,我还没有确定如何完成:
Now i think if figured out how to get the hashes of all the commits that were committed to the branch but not merged into master using git cherry master <branchname>
. 现在我想如果弄清楚如何获取所有提交给分支但未使用git cherry master <branchname>
合并到master中的提交的哈希值。 With this i could go hash by hash and figure out everything but if you have a lot of commits this could be time consuming. 有了这个我可以通过哈希哈希并弄清楚一切,但如果你有很多提交,这可能是耗时的。 Notice i'm not wanting to compare to current state of master. 请注意,我不想与当前的主人状态进行比较。 I think the key is knowing the hash of master that you created your branch off of but i'm not exactly sure how to determine this. 我认为关键是要知道你创建分支的master的哈希值,但我不确定如何确定它。
To find where your current checkout diverged from the master branch, 要查找当前结帐与主分支的分歧,
base=`git merge-base master HEAD`
echo $base
to find out what files have been changed since then, 找出自那时以来改变了哪些文件,
git diff --name-only $base HEAD
to show the accumulated difference 显示累积的差异
git diff $base HEAD
When you want to describe an entire series of commits you can use the syntax in the answer Gabriele Petronella linked above, master..HEAD
is shorthand for HEAD ^master
which means "all commits reachable from HEAD, but not including commits reachable from master". 当你想要描述一系列提交时,你可以使用上面链接的Gabriele Petronella的答案中的语法, master..HEAD
是HEAD ^master
简写,这意味着“所有提交都可以从HEAD访问,但不包括从master可以访问的提交” 。 Missing endpoints default to HEAD, so you can say git log --oneline master..
缺少端点默认为HEAD,因此您可以说git log --oneline master..
Assuming you branched from master
, 假设你从master
分支,
1. What files have changed since branching? 1.自分支以来哪些文件发生了变化?
git diff master...<branchname> --name-only
2. What is the full diff since branching? 2.分支后的完整差异是什么?
git diff master...<branchname>
3. What is the commit log since branching? 3.分支后的提交日志是什么?
git log master..<branchname>
You do not need to specify <branchname>
if you have it checked out (eg, git diff master...
). 如果你签出了它,你不需要指定<branchname>
(例如, git diff master...
)。
Note: git diff
requires triple dot ...
and git log
requires double dot ..
to get the behavior that you are asking for. 注意: git diff
需要三点...
而git log
需要双点..
来获取你要求的行为。
For explanations on dot syntax, see: 有关点语法的说明,请参阅:
For the list of files changed and the actual diff, it makes more sense if you know 2 commits between which you wanna compare. 对于更改的文件列表和实际差异,如果您知道要比较的2个提交,则更有意义。
If you want to see the diff between START_SHA1
and END_SHA1
, you could do: 如果你想看到START_SHA1
和END_SHA1
之间的差异,你可以这样做:
git diff START_SHA1 END_SHA1
If you want just the list of files, you could do: 如果您只想要文件列表,您可以:
git diff --name-only START_SHA1 END_SHA1
If you also want to know what type of change went into the file (like A
, M
, D
, C
, R
, U
), you could do: 如果您还想知道文件中的更改类型(如A
, M
, D
, C
, R
, U
),您可以执行以下操作:
git diff --name-status START_SHA1 END_SHA1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.