没有什么可以比较的.没什么可比较的,分支是完全不同的提交历史 [英] There isn't anything to compare. Nothing to compare, branches are entirely different commit histories

查看:31
本文介绍了没有什么可以比较的.没什么可比较的,分支是完全不同的提交历史的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机器上安装了 CMS 主题.我正在通过 git 跟踪对它的更改并决定在 GitHub 上进行备份,以便我可以分享这些更改.

I have a CMS theme installed on my machine. I'm tracking changes to it via git and decided to back it up on GitHub so I could share those changes.

所提供的主题也可在 GitHub 上找到.在我的机器上我添加了这是一个远程上游.现在我可以很容易地看到我的主人之间的变化和远程上游使用以下命令:

The theme as provided is also available on GitHub. On my machine I have added this as a remote upstream. Now I can easily see the changes between my master and the remote upstream by using the following command:

git diff --color master upstream/number

如果我可以在 GitHub 上添加远程上游,我可以轻松分享这些更改.GitHub上可以设置这个关系吗?

If I could add the remote upstream on GitHub I could easily share these changes. Is it possible to set this relationship on GitHub?

我尝试了以下方法:

git push -u origin upstreambranch

向 GitHub 上的 master 添加一个 upstreambranch.然而试图比较两个分支都不起作用,我在 GitHub 上得到的结果是:那里没有什么可比的"

which adds an upstreambranch to the master on GitHub. However trying to compare both branches doesn't work, the result I get on GitHub is that: "There isn't anything to compare"

是否有其他方法来比较这些?

Is there an alternative way to compare these?

推荐答案

The Short Answer

看起来 GitHub 不会让你比较分支,因为 他们不实际上共享任何相同的历史记录,即使他们可能共享大部分相同的文件和代码.

The Short Answer

It looks like GitHub won't let you compare the branches because they don't actually share any of the same history at all, even though they may share much of the same files and code.

这是我用你的 repo 制作的临时叉的屏幕截图,我试图在那里将 masterupstreambranch 进行比较,就像您描述的那样.注意错误留言:

Here is a screenshot of the temporary fork I made of your repo, where I tried to compare master with the upstreambranch, like you described. Notice the error message:

它说:

没有什么可以比较的.

masterupstreambranch 是完全不同的提交历史.

master and upstreambranch are entirely different commit histories.

长答案

您可能下载了原始源并将其添加到一个全新的回购而不是克隆原始回购,对吗?这样做会让事情变得如此您的存储库的历史将完全不同原始仓库的历史,因为你的新仓库不会有任何相同的使用相同的 sha ID 提交.

The Long Answer

You probably downloaded the original source and added it to a completely new repo instead of cloning the original repo, right? Doing that will make it so that the history of your repo will be completely different from the history of the original repo, since your new repo won't have any of the same commits with the same sha IDs.

您可以通过对 master 分支和上游分支:

You can see that by doing a reverse log of your master branch and the upstreambranch:

# Your first commit, see commit sha
git log --reverse master
commit c548d7b1b16b0350d7fbdb3ff1cfedcb38051397 # <== HERE
Author: Padraic Stack <padraic.stack@nuim.ie>
Date:   Wed Apr 2 15:11:28 2014 +0100

    First commit of everything

# First commit sha of the original repo
git log --reverse upstreambranch
commit 105a12817234033c45b4dc7522ff3103f473a862 # <== THERE
Author: Jeremy Boggs <jeremy@clioweb.org>
Date:   Mon Feb 22 16:00:53 2010 +0000

    Creates repo directories for the Seasons theme.

解决方案

如果您在原始历史记录之上重做提交,那么您应该能够比较分支.有几种不同的方法可以重做提交,包括

Solutions

If you redo your commits on top of the original history, you should then be able to compare the branches. There are several different ways that you can redo your commits, including

git rebase --onto

git cherry-pick

如果需要,您也可以手动重做每次提交.

You also can redo each commit manually, if you have to.

这篇关于没有什么可以比较的.没什么可比较的,分支是完全不同的提交历史的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆