gpt4 book ai didi

Azure DevOps - compare two commits right in the web UI?(Azure DevOps-在web UI中比较两个提交?)

转载 作者:bug小助手 更新时间:2023-10-22 17:35:13 38 4
gpt4 key购买 nike



This is surely something simple I'm overlooking. In the Azure DevOps web interface (not integrated as part of an IDE), I see how to compare any commit to its parent, but I can't figure out how to compare it to an arbitrary commit.

这肯定是我忽略的一件简单的事情。在Azure DevOps web界面(未作为IDE的一部分集成)中,我看到了如何将任何提交与其父级进行比较,但我不知道如何将其与任意提交进行比较。



ie, I'm looking for the equivalent of GitHub's compare/hash1..hash2 functionality.

即,我正在寻找相当于GitHub的compare/hash1..hash2功能。



The appeal is that the web UI is a view/tool common to everyone, and presumably I could get a link to the specific diff I'm interested in and share it with colleagues.

吸引人的是,web UI是每个人都通用的视图/工具,据推测,我可以获得我感兴趣的特定差异的链接,并与同事共享。



The web UI suggests it might be possible because when viewing the changes for a particular commit it has text Diff to Parent 1 - <my commit hash> but I haven't figured out how to change Parent 1.

web UI表明这可能是可能的,因为在查看特定提交的更改时,它有文本Diff to Parent 1-<my commit hash>,但我还没有弄清楚如何更改Parent 1。


更多回答

agreed - microsoft UI, every time...smh

同意-微软用户界面,每次。。。smh

优秀答案推荐

If you go to the list of branches for a repository, you can click on ... (More Actions) on one of the branches and choose Compare branches

如果转到存储库的分支列表,可以单击。。。(更多操作),然后选择“比较分支”



This will take you to a URL in the form:
https://dev.azure.com/{organisation}/{project}/_git/{repository}/branches?baseVersion=GB{baseBranch}&targetVersion=GB{targetBranch}&_a=files

这会将您带到以下格式的URL:https://dev.azure.com/{organization}/{project}/_git/{repository}/分支机构?baseVersion=GB{baseBranch}targetVersion=GB{targetBranch}_a=文件



You can then change the baseVersion and targetVersion parameters in the query string. These can take the following forms, and can be mixed and matched:

然后,您可以更改查询字符串中的baseVersion和targetVersion参数。这些可以采取以下形式,并且可以混合和匹配:




  • GB{branchName}

  • GC{commitHash}

  • GT{tagName}



Just in case that link gets broken, clicking "View Merge Changes" on a pull request takes you to the same page but with a slightly different URL https://dev.azure.com/{organisation}/{project}/_git/{repository}/branchCompare?baseVersion=GC{baseCommit}&targetVersion=GC{targetCommit}&_a=files

为了防止链接断开,在拉取请求上单击“查看合并更改”会将您带到同一页面,但URL略有不同https://dev.azure.com/{organization}/{project}/_git/{repository}/branchCompare?baseVersion=GC{baseCommit}targetVersion=GC{targetCommit}_a=文件



I'm not sure if there's a nicer way of comparing commits from the UI, as it only shows branches and tags, but if you do it this way you don't have to temporarily tag commits or create temporary branches just to get a diff that shows all of the changed files.

我不确定是否有更好的方法来比较来自UI的提交,因为它只显示分支和标记,但如果你这样做,你不必临时标记提交或创建临时分支,只需获得一个显示所有更改文件的diff。



If you want to compare two arbitrary commits for one file, navigate to the file in the repo, select the compare tab, and apply the appropriate commit range.

如果要比较一个文件的两个任意提交,请导航到repo中的文件,选择“比较”选项卡,然后应用适当的提交范围。



enter image description here



If you want to compare two arbitrary commits for all files , you can create tags at commits , then compare them. This will give you a list of commits between them and allow you to show the diffs.

如果要比较所有文件的两个任意提交,可以在提交时创建标记,然后进行比较。这将为您提供它们之间的提交列表,并允许您显示差异。



enter image description here



enter image description here



enter image description here



enter image description here



For details, you can refer to this case.

有关详细信息,您可以参考本案例。



The Devops UI does now allow a comparison of the commits between branches as well as files. The URL is very similar to the one detailed in George Heylar's answer, you just change the end of the URL from 'files' to 'commits':

Devops UI现在允许比较分支和文件之间的提交。URL与George Heylar的回答中详细描述的非常相似,您只需将URL的末尾从“files”更改为“commits”:


https://dev.azure.com/{organisation}/{project}/_git/{repository}/branches?baseVersion=GB{baseBranch}&targetVersion=GB{targetBranch}&_a=commits

https://dev.azure.com/{organization}/{project}/_git/{repository}/分支机构?baseVersion=GB{baseBranch}targetVersion=GB{targetBranch}_a=提交


The short way to do that via the UI if 'Compare Branches' is not disabled



  1. Open the Branch list for your project:


Azure DevOps Branch list



  1. Click the vertical ellipsis button against the first branch you want to compare:


Branch row options list



  1. Select 'Compare branches' to open the screen below. If the 'Compare branches' option is disabled see the longer approach below.


Top of the Branch compare page



  1. Select the branch to compare to in the second combo and then you will see a list of the commit differences between the two branches:


Branch compare page showing commit differences between master branch and a release branch



  1. If you want to see the file differences just choose the 'Files' option in the not terribly obvious tab control:


Compare Commits or Files tab


The long way to achieve that via the UI if 'Compare Branches' is disabled



  1. Open the Branch list for your project:


Azure DevOps Branch list



  1. Click the vertical ellipsis button against the first branch you want to compare:


Branch row options list



  1. Select 'Set as default branch'



  2. Repeat the same process for the second branch you want to compare to:




Branch row options list



  1. This time select Select 'Set as compare branch'



  2. Finally open the ellipsis menu again for the branch you set as the default branch (i.e. the one you picked in step 3 above)




Branch ellipsis menu when default and compare branches have been selected



  1. Select the 'Compare branches' menu item and that will open the 'Branch Compare' page:


Branch compare page



The "Diff to Parent 1" feature is described in "Commit details / What are the changes included in the commit?"

“提交详细信息/提交中包含哪些更改?”中介绍了“与父级1的差异”功能



https://learn.microsoft.com/en-us/azure/devops/repos/git/_img/commit-details/10difftoparent.png?view=azure-devops




Diff to parent - Click on Diff on parent1 in the Source Explorer pane to view the difference between the current commit and its parent commit.




One can see what Parent1 references in the diff view itself:

可以在diff视图中看到Parent1引用了什么:



https://learn.microsoft.com/en-us/azure/devops/repos/git/_img/commit-details/11sidebyside.png?view=azure-devops



But I don't see any web URL which could help reference that diff. Hence my initial Azure DevOps Git API that I proposed before.

但我没有看到任何web URL可以帮助引用这种差异。因此,我之前提出了我最初的Azure DevOps Git API。



Easy...

容易的


If you would like to compare two commits of a branch...

如果您想比较一个分支的两次提交。。。



  1. Go To branches.

  2. Create a new branch from branch where you want to do comparison.

  3. Create branch with the specific commit.
    enter image description here

  4. Compare newly created branch with original branch.


更多回答

Just want to add a comment that if you get the commits backwards in the URL, it will just tell you that there are no changes between the two commits (instead of an error message or something). Try flipping them around.

只想添加一条注释,如果您在URL中反向提交,它只会告诉您两次提交之间没有任何更改(而不是错误消息或其他什么)。试着把它们翻来翻去。

Nice! Too bad they don't have an easier way to do this

美好的可惜他们没有更简单的方法

This is exactly what I was looking for. Thanks for sharing

这正是我想要的。感谢分享

... then click the "Files" tab to see the changed files with the added and deleted lines marked appropriately.

…然后单击“文件”选项卡,查看已更改的文件,并适当标记添加和删除的行。

thanks Hugh! creating tags is not my preference, but it certainly works in a pinch.

谢谢休!创建标签不是我的偏好,但它在必要时确实有效。

Absolutely amazing answer!

绝对惊人的答案!

This answer is great and should be marked as "Answer". This is the way how to compare arbitrary commits right from the user interface.

这个答案很棒,应该标记为“答案”。这就是如何从用户界面比较任意提交的方法。

New branch... from History also works to compare arbitrary commits (branches in this case). That is, creating shord-lived branch that you can then compare and delete. Ofcourse one may prefer using tags... Love that it automatically names the branch (that includes the commit hash), but it does for tags too... so perhaps no particular advantage.

新建分支。。。from History还可以比较任意提交(在本例中为分支)。也就是说,创建shord live分支,然后可以对其进行比较和删除。当然,人们可能更喜欢使用标签。。。喜欢它自动命名分支(包括提交哈希),但它也为标记命名。。。所以也许没有什么特别的优势。

fantastic. I'm going to leave George Haylar's answer as the selected answer tho, as the Q is really about Commits, vs. Branches, but I'm very grateful you pointed this out anyhow. I'll use it all the time.

好极了我将把George Haylar的答案作为选定的答案,因为Q实际上是关于委员会与分支机构的,但我非常感谢你无论如何都指出了这一点。我会一直用它。

Although this is quite similar to my answer, this actually only lets you compare branches or tags, not arbitrary commits (without changing the URL as I described), and you shouldn't be changing your default branch for this reason. The default branch is e.g. master or main, and it's a repository-wide setting, not a personal setting. You can change your "compare branch" and then "compare branches" on another branch, but again this doesn't let you compare arbitrary commits, and it's just as easy to leave your default branch as your compare branch and change them on the comparison page.

尽管这与我的答案非常相似,但实际上这只允许您比较分支或标记,而不是任意提交(如我所述,不更改URL),因此您不应该更改默认分支。默认分支是例如master或main,它是整个存储库的设置,而不是个人设置。您可以更改“比较分支”,然后在另一个分支上更改“比较分枝”,但同样,这不允许您比较任意提交,并且可以像保留比较分支一样轻松地保留默认分支,并在比较页面上更改它们。

So there is no answer to stackoverflow.com/questions/61059102/… ?

所以stackoverflow.com/questions/61059102/…没有答案?

@FDM None that I know of indeed. Let's see if someone has an answer to your question.

@FDM我不知道。让我们看看是否有人能回答你的问题。

I've looked into doing a manual HTTP call to the route mentioned, but it's near impossible to get file paths and commit IDs from the API SDK properly. I'm giving it up for now, until someone has a golden tip. But I don't count on it. :)

我已经考虑过对上面提到的路由进行手动HTTP调用,但从API SDK中正确获取文件路径和提交ID几乎是不可能的。我暂时放弃,直到有人得到一个金色的小费。但我不指望

hm, thanks for this idea, but I'm not crazy about modifying the repository just to examine it.

嗯,谢谢你的想法,但我并不热衷于修改存储库只是为了检查它。

Some of the other answers already cover the idea of creating temporary branches (or tags) to permit comparison of commits - perhaps it would be better to suggest an edit (once you have the appropriate permissions) on one of the other answers?

其他一些答案已经涵盖了创建临时分支(或标记)以允许比较提交的想法——也许建议对其他答案之一进行编辑(一旦您拥有适当的权限)会更好?

................

。。。。。。。。。。。。。。。。

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com