Git 从同事克隆而来';s的电脑,现在从Bitbucket上拉下来的下载量还是很多的

Git 从同事克隆而来';s的电脑,现在从Bitbucket上拉下来的下载量还是很多的,git,Git,我们有一个相当大的Git存储库,我们的互联网连接速度非常慢 我的同事已经有了存储库的最新副本,所以我做了一个 git clone him:/home/foo/repo 在LAN中-哪一个速度快:) 在那之后,他做了一些更改,所以我做了一个git-pull。在这期间,我与我的公司发生了冲突 接下来,我做了 git remote rename origin him git remote add <BITBUCKETURL> 被拒绝(没有快进) 所以我试过了 git pull orig

我们有一个相当大的Git存储库,我们的互联网连接速度非常慢

我的同事已经有了存储库的最新副本,所以我做了一个

git clone him:/home/foo/repo
在LAN中-哪一个速度快:)

在那之后,他做了一些更改,所以我做了一个
git-pull
。在这期间,我与我的公司发生了冲突

接下来,我做了

git remote rename origin him
git remote add <BITBUCKETURL>
被拒绝(没有快进)

所以我试过了

git pull origin
但是现在,Git想要下载兆字节的数据,我不明白。 我认为Git足够聪明,可以交叉匹配它已经拥有的对象。对吗?此外,我尝试克隆并添加Bitbucket URL,但没有进行任何合并;同样的问题

我该怎么做才能解决这个问题

编辑以解决评论中的问题

  • 我知道没有其他分支,
    git pull origin master
    具有相同的效果
  • 执行git
    拉取原始主机
    打印:
    远程:计数对象:1535
    -不可能同时执行这么多操作
  • 我确实比较了日志,没有在线更改(Bitbucket),这些更改不在我克隆的同事的计算机上
编辑(很多以后)


我后来发现,虽然无法验证这一点,但我可能在远程存储库中犯了一个错误,并添加了一个完全不同的repo。这就解释了一切。

我相信重命名更改了文件系统上为该分支存储的引用,因此可能修改了某些内容,阻止它在不下载的情况下链接对象

您可以通过临时将原点指向同事的repo,让它重新复制所需的数据,然后再次将原点指向bitbucket来解决此问题。首先

git远程设置url-him:/home/foo/repo

然后,
git-pull-origin-master
将有望通过局域网重新下载相同的1535个对象。如果确实如此,那么您可以再次使用
设置url
将其指向bitbucket

git远程设置rul


在这一点上,git应该拥有所有需要的对象,因为只有远程url会发生更改,因此,
git pull
应该提供
已经更新的

这不是一个直接的答案,但是对于注释来说太大了。 我只是试着重现你的情况,它对我来说就像预期的一样(没有从bitbucket上下载)

这不适用于您的一些可能原因:

1) 检查同事存储库-它是否有正确的
远程设置?我不确定,但git可能使用remotes元数据来理解存储库之间的关系(只是猜测)

2) 可能同事的存储库中的bitbucket不是最新的?因此,当你做拉,它只是下载新的数据。首先尝试更新同事的存储库

下面是我用来检查问题的shell脚本,您可以使用类似的方法来找出导致您看到的行为的原因:

# Change this to your repository url
BITBUCKET_URL=git@bitbucket.org:user/project

git clone $BITBUCKET_URL project
# Cloning into 'project'...
# Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx.xxx' to the list of known hosts.
# remote: Counting objects: 163, done.
# remote: Compressing objects: 100% (154/154), done.
# remote: Total 163 (delta 53), reused 0 (delta 0)
# Receiving objects: 100% (163/163), 3.62 MiB | 1.30 MiB/s, done.
# Resolving deltas: 100% (53/53), done.
# Checking connectivity... done.

mkdir mycopy
cd mycopy
git clone ../project .
# Cloning into '.'...
# done.
ls
# application.py  database.py  README.md  requirements.txt  static
git remote -v show
# origin    /home/seb/test/gitdist/mycopy/../project (fetch)
# origin    /home/seb/test/gitdist/mycopy/../project (push)

git remote rename origin local
git remote add origin $BITBUCKET_URL
git remote -v show
# local /home/seb/test/gitdist/mycopy/../project (fetch)
# local /home/seb/test/gitdist/mycopy/../project (push)
# origin    git@bitbucket.org:owner/project.git (fetch)
# origin    git@bitbucket.org:owner/project.git (push)

git pull origin
# Warning: Permanently added the RSA host key for IP address 'xxx.xxx.xxx.xxx' to the list of known hosts.
# From bitbucket.org:owner/project
#  * [new branch]      master     -> origin/master
# You asked to pull from the remote 'origin', but did not specify
# a branch. Because this is not the default configured remote
# for your current branch, you must specify a branch on the command line.
上面包含了每个命令的输出,您可以看到有初始存储库下载到
项目
文件夹中(这模拟了您同事的存储库),然后在我重命名源时,本地存储库中没有下载,将新源添加为bitbucket url并转到
git pull origin

更新:使用两个git版本进行检查 正如在对其他答案的评论中提到的,涉及到两个版本的git—在机器上的git 1.9.4和本地的git 2.1.4。 我在本地也有2.1.4版本,因此我还通过以下方式获得了1.9.4版本:

git clone git://git.kernel.org/pub/scm/git/git.git 
git checkout v1.9.4
make configure
./configure --prefix=/usr
make all
./git --version
# git version 1.9.4
# Change this to your repository url
BITBUCKET_URL=git@bitbucket.org:bosonz/gameofdata.git 

GIT194=./git/git

$GIT194 --version

$GIT194 clone $BITBUCKET_URL project
# Cloning into 'project'...
# ....
# (the rest is unchanged)
现在,我以这种方式修改了测试脚本:

git clone git://git.kernel.org/pub/scm/git/git.git 
git checkout v1.9.4
make configure
./configure --prefix=/usr
make all
./git --version
# git version 1.9.4
# Change this to your repository url
BITBUCKET_URL=git@bitbucket.org:bosonz/gameofdata.git 

GIT194=./git/git

$GIT194 --version

$GIT194 clone $BITBUCKET_URL project
# Cloning into 'project'...
# ....
# (the rest is unchanged)

结果-仍然没有问题,从bitbucket下载仍然只完成一次。

只是好奇。。。我们在这里谈的有多大?
him:
scheme?你克隆到哪里了?当你添加bitbucket时,为什么你没有选择一个名称?为什么
git pull origin
,而不仅仅是
git pull origin master
?在远程repo上有任何更改?不起作用<代码>git克隆;git远程设置url源;git pull原始主机
$git pull警告:无常见提交远程:计数对象:1535,完成。远程:压缩对象:100%(800/800),完成。接收对象:15%(233/1535),4.74 MiB | 32.00 KiB/s
我还再次将同事的repo与远程bitbucket repo的直接克隆进行了比较-肯定存在常见的提交(一个尚未推送的提交),这可能是不同git版本之间的问题吗?我的同事使用的是1.9.4-我使用的是2.1.4?哇,谢谢你的修改。他的回购协议过去是,现在也是最新的。你不是碰巧用不同的git版本测试的吗?查看我对另一个答案的评论。@Alex我开始写,检查不同git版本对我来说很复杂,但实际上它没有更新答案的细节。简言之,即使使用不同的git版本也没有问题。我建议您在github上创建一个小型测试repo,并尝试重现该问题,如果没有问题,您可以尝试进行干净的设置(在同事的机器上从头开始克隆存储库,并重复您的本地设置)。我认为他是用https克隆的,我是用ssh克隆的。也许这就是问题的原因。必须检查。@Alex对我来说,即使使用http/ssh,它仍然可以工作,那么通过ssh而不是通过文件夹从同事处进行克隆怎么样?(您可能有一个本地SSH服务器)