我只是想知道是否有办法简单地在GitHub中区分两个分支?我知道GitHub有能力做到这一点,因为当我们进行代码评论时,它会很好地列出所有差异。我只是想知道是否有一种方法可以做到这一点,没有任何代码审查比较说分支到分支或承诺提交?因此,当我将某些内容推送到我的远程分支时,我想看看我的差异看起来如何在创建PR之前,那么它会非常有用。
我总是可以在控制台中进行git diff但是它实际上并不像它在GitHub的Web UI中显示的那样好看。有什么想法吗?
答案 0 :(得分:40)
使用compare功能完成此操作。
答案 1 :(得分:20)
答案 2 :(得分:1)
还有一种在GitHub上实现此目标的方法,只需尝试使用要比较的分支创建一个新的Pull Request。
例如
分支1 <-分支2 要么 分支2 <-分支1
在底部,您可以看到文件和这些分支之间的提交差异。 如果您不想合并这两个请求,就不要创建Pull请求。
答案 3 :(得分:0)
扩展@Ari M的答案。 URL格式如下:
def substrings(length = nil)
subs = []
# in the case of 'cats' the length is 4
# so this is making an array UP TO BUT NOT INCLUDING 4
# [0,1,2,3].each do ...
# let's take 0
(0...self.length).each do |start_idx|
# start_idx = 0 the first time through this each
# Array from start_idx UP TO BUT NOT INCLUDING 4
# so the FIRST time through this is 0, second time through is 1, ...
#[0,1,2,3].each do ...
(start_idx...self.length) do |end_idx|
# end_idx = 0
# slice of the string from the 0th to the 0th value (first letter)
sub = self[start_idx..end_idx]
subs << sub
end
end
if length.nil?
subs
else
subs.select { |str| str.length == length}
end
end
https://
<REPO URL>
/compare/
<SOURCE BRANCH OR COMMIT>
{ {1}}
请注意...
和<TARGET BRANCH OR COMMIT>
之间的difference(2和3点)。
2个点:显示TARGET拥有但SOURCE没有的所有提交,以及SOURCE拥有但TARGET没有的所有提交。
3个点:显示TARGET有但SOURCE没有的所有提交。 您通常想要这个。
例如查看与..
回购中的...
相比,gh-pages
分支中添加了什么:
https://github.com/octocat/linguist/compare/master...gh-pages