在Gitlab上,如何比较两个不同提交的文件?我知道在命令行git上,该命令是:
git diff commit1 commit12-file_name
在gitlab上执行此操作的链接格式是什么?
看到我的相关问题
twh*_*ney 16
其他答案都没有正确的步骤来通过当前版本的 Gitlab GUI 显示两个分支之间的差异。为此:
master(或任何默认分支的名称)。它将比较提交,您将能够在列表中找到文件。
1)转到存储库>比较
2)粘贴:https
://gitlab.com/ $ USER / $ REPO / compare?from = $ SHA1&to = $ SHA2网址3)按下Enter键(注意:gitlab将设置'Source'和'目标”正确)
4)单击“比较”按钮
看起来比较的直接网址如下
# compare URL, where ref_source and ref_target can be commit SHA, tag, or branch
https://${gitlab_host}/${repo_path}/compare/${ref_target}...${ref_source}
# tag example 1, comparing tag v1.5.1 to master
https://${gitlab_host}/${repo_path}/compare/v1.5.1...master
# tag example 2, comparing tag v1.5.1 to tag v1.5.2
https://${gitlab_host}/${repo_path}/compare/v1.5.1...v1.5.2
# commit example 1, comparing commit SHA to master
https://${gitlab_host}/${repo_path}/compare/f6098082f...master
# commit example 2, comparing commit SHA to another commit SHA
https://${gitlab_host}/${repo_path}/compare/f6098082f...2b8daf28
Run Code Online (Sandbox Code Playgroud)
要在两次提交中比较单个文件,首先需要获取文件的 blob id,并将其附加到比较 url 后面的 octothorp ( #) ;必须找到一种方法来获得那个 id
# compare URL, where ref_source and ref_target can be commit SHA, tag, or branch, and file_blob
https://${gitlab_host}/${repo_path}/compare/${ref_target}...${ref_source}#${file_blob}
Run Code Online (Sandbox Code Playgroud)
您可以打开两个选项卡:
Repository -> Commits,从那里您可以方便地找到SHA任何给定的提交(右侧有复制按钮);Repository -> Compare),然后在顶部的source和中target,经过SHA要比较的两个提交的字符串。您首先需要获取您感兴趣的文件路径的sha1摘要(例如使用sha1sum命令)。然后,您可以构建 URL 以显示两个git ref (即分支名称或提交哈希或标签)之间的差异,如下所示:
https://gitlab.com/<project>/-/compare/<ref1>...<ref2>#<sha1>
Run Code Online (Sandbox Code Playgroud)
以下是文件名为AN/R5/L15/S2018/IDS/000/020/RUANR5L15S2018IDS20864.json的示例。它的 sha1 是f88a5e03ecc7854e8955927af33f2ea9d090ddaf:
$ echo -n AN/R5/L15/S2018/IDS/000/020/RUANR5L15S2018IDS20864.json | sha1sum
f88a5e03ecc7854e8955927af33f2ea9d090ddaf
Run Code Online (Sandbox Code Playgroud)
使用以下 URL 完成878bd4f4f7edbabad3c691a7df3e317348d4ca77和59e63f529a7fe5f28131dec36f253dca46b8ba9c提交之间的比较:https: //git.en-root.org/tricoteuses/data.tricoteuses.fr/Agenda_XV/-/compare/5 9e63f529a7fe5f28131dec36f253dca46b8ba9c...878bd4f4f7edbabad3c691a7df3e317348d4ca77#f88a5e03ecc7854e8955927af33f2ea9d090ddaf
该页面还将显示其他差异,而不仅仅是您感兴趣的差异。但它会将您移到文件差异开始的位置,您可以忽略其余部分。
有一些 GitLab 功能请求可以让用户将来更容易发现这一点。
| 归档时间: |
|
| 查看次数: |
11200 次 |
| 最近记录: |