git 如何比较 Bitbucket 中的两个修订版?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21437196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to compare two revisions in Bitbucket?
提问by brian.keng
My team is using Bitbucket for our git repository and we've recently starting using the pull request functionality for code reviews. It works fine on the first review, but if it goes through multiple iterations (that is, changes are made and pull request updated), I would like to see a link with just the new changes that were made since the last code review.
我的团队正在将 Bitbucket 用于我们的 git 存储库,我们最近开始使用拉取请求功能进行代码。它在第一次时运行良好,但如果它经过多次迭代(即,进行了更改并更新了拉取请求),我希望看到一个链接,其中包含自上次代码以来所做的新更改。
I looked into the "compare" functionality but the UI looks like it can only compare between branches. Is there a simple way to get a diff between two commits?
我查看了“比较”功能,但 UI 看起来只能在分支之间进行比较。有没有一种简单的方法来获得两次提交之间的差异?
回答by Night Owl
This is just a slight modification to the answers already given but adding #diff to the end instead of #commits is usually what I'm looking for. Also as others may have mentioned the best results for me are usually obtained by placing the newer commit first and the older one second but that will depend on your particular needs.
这只是对已经给出的答案的轻微修改,但在末尾添加 #diff 而不是 #commits 通常是我正在寻找的。此外,正如其他人可能提到的,对我来说最好的结果通常是通过将较新的提交放在第一位,将较旧的提交放在一秒钟内来获得,但这取决于您的特定需求。
https://bitbucket.org/<OWNER>/<REPO>/branches/compare/<commit-hash>..<commit-hash-older>#diff
回答by Aguardientico
Try something like:
尝试类似:
https://bitbucket.org/<OWNER>/<PROJECT>/branches/compare/<commit1>..<commit2>#commits
https://bitbucket.org/<OWNER>/<PROJECT>/branches/compare/<commit1>..<commit2>#commits
Taken from: https://bitbucket.org/site/master/issue/4779/ability-to-diff-between-any-two-commits
摘自:https: //bitbucket.org/site/master/issue/4779/ability-to-diff-between-any-two-commits
回答by Alastair Wilkes
The search fields in the branch/tag dropdowns on the Compare page on bitbucket.org now supports pasted-in commit hashes.
bitbucket.org 上比较页面上的分支/标签下拉列表中的搜索字段现在支持粘贴提交哈希。
So now you can just go to https://bitbucket.org/<owner>/<repo>/branches/compare/
and paste the hashes into the dropdowns instead of URL hacking!
因此,现在您可以直接https://bitbucket.org/<owner>/<repo>/branches/compare/
将哈希值粘贴到下拉列表中,而不是进行 URL 黑客攻击!
回答by Tao
Bitbucket supports comparing tags now.
Bitbucket 现在支持比较标签。
https://bitbucket.org/<OWNER>/<PROJECT>/branches/compare/<tag1>%0D<tag2>
回答by santiago arizti
I have Bitbucket Server, version:v4.4.1
我有 Bitbucket 服务器,版本:v4.4.1
The answer with me was this.
我的答案是这样的。
http://<path-to-my-server>/projects/<project-name>/repos/<repo-name>/commits/<old>?to=<new>
I was looking for this answer because in my project we use git submodules, and in pull requests I can only see the old commit sha vs the new commit sha of each submodule that changed. There is no link to click or anything (that I know of) to jump to this diff view. This url allows me to view what changed in submodules too.
我正在寻找这个答案,因为在我的项目中,我们使用 git 子模块,而在拉取请求中,我只能看到旧的提交 sha 与每个更改的子模块的新提交 sha。没有单击链接或任何(我知道的)跳转到此差异视图的链接。这个 url 也允许我查看子模块中的更改。
Btw, if someone knows of a better way of comparing two commits in submodules during a pull request, please let me know.
顺便说一句,如果有人知道在拉取请求期间比较子模块中的两次提交的更好方法,请告诉我。
回答by Juanito Fatas
The Bitbucket compare view format is following:
Bitbucket 比较视图格式如下:
https://bitbucket.org/<owner>/<repo>/branches/compare/<new>%0D<old>
Given an example ged/ruby-pg
(RubyGem, a ruby library):
举一个例子ged/ruby-pg
(RubyGem,一个 ruby 库):
To compare two releases (from v0.18.1 to v0.18.2)
比较两个版本(从 v0.18.1 到 v0.18.2)
https://bitbucket.org/ged/ruby-pg/branches/compare/v0.18.2%0Dv0.18.1
https://bitbucket.org/ged/ruby-pg/branches/compare/v0.18.2%0Dv0.18.1
To compare two revisions (from f97dd6c to 22a3612)
比较两个修订版(从 f97dd6c 到 22a3612)
回答by Harsh Phoujdar
回答by Isaac Baker
You can also do this inside of a pull request, say after someone makes a push to a branch to fix review findings. To my knowledge there's no UI for this yet, but you can enter the url like this:
您也可以在拉取请求中执行此操作,例如在有人推送到分支以修复结果之后。据我所知,目前还没有用户界面,但您可以像这样输入网址:
https://<bitbucket-server>/projects/<PROJECT>/repos/<REPO>/pull-requests/<PR-NUM>/<commit-hash>?since=<commit-hash-older>
https://<bitbucket-server>/projects/<PROJECT>/repos/<REPO>/pull-requests/<PR-NUM>/<commit-hash>?since=<commit-hash-older>
回答by Siddharth
What worked for me was https://bitbucket.org/-theusername-/-projectnamealllowercase-/branches/compare/-Leftalphanumberic_commitcode-..-Rightalphanumeric_commit-#commits
对我有用的是 https://bitbucket.org/-theusername-/-projectnamealllowercase-/branches/compare/-Leftalphanumberic_commitcode-..-Rightalphanumeric_commit-#commits
Replace the -username-
with your username
-username-
用你的替换username
Thanks to @Aguardientico
感谢@Aguardientico
回答by Cyrille Cormier
Create a light tag to the commit(s) you want to compare. git -a [tagname] [commit_sha]
为要比较的提交创建一个轻量级标签。git -a [标记名] [commit_sha]
Then in Bitbucket, in the compare menu (the one to do pull requests) simply compare with tags.
然后在 Bitbucket 中,在比较菜单(执行拉取请求的那个)中简单地与标签进行比较。