将新分支推送到远程再次推送所有内容

时间:2021-02-20 16:24:11

I created a new branch develop from master. Then I pushed the new branch to the remote using git push -u origin develop from develop branch. This command took too much time to push the new develop branch. The output is:

我创建了一个从master开发的新分支。然后我使用git push -u origin from develop branch将新分支推送到远程。这个命令花了太多时间来推动新的开发分支。输出是:

$ git push -u origin develop
Counting objects: 11531, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6217/6217), done.
Writing objects: 100% (11531/11531), 38.90 MiB | 142.00 KiB/s, done.
Total 11531 (delta 6220), reused 7234 (delta 3876)
remote: 
remote: Create pull request for develop:
remote:   https://bitbucket.org/scupids/supertext/pull-requests/new?source=develop&t=1
remote: 
To https://knoxxs@bitbucket.org/scupids/supertext.git
 * [new branch]      develop -> develop
Branch develop set up to track remote branch develop from origin.
$

From the output it seems that it pushed everything again. It pushed about 40 MiB of data.

从输出看起来它再次推动了一切。它推动了大约40 MiB的数据。

Just for the reference the origin is hosted on Bitbucket.

仅供参考,原产地托管在Bitbucket上。

Following is the output of the log command:

以下是log命令的输出:

$ git log --oneline --graph --all --decorate
* faa7d51 (HEAD, origin/master, origin/develop, master, develop) adds profile data to customer DTO
* 1f562c1 UI/ latest compiled css
* d19ccb0 UI/ Added customer stream and basic styling
.
.
.

I am not able to understand why this is happening?

我无法理解为什么会这样?

2 个解决方案

#1


2  

Git does not push everything every time.

Git每次都不会推送所有内容。

Possible explanation for this case: you cloned some repository, then changed your local repository's origin url to point to another (possibly empty) repository (git doesn't invalidate remotes/origin/* branches in this case). Then you pushed, and git found no commits on the other side, so it had to push every commit from develop.

这种情况的可能解释:您克隆了一些存储库,然后将您的本地存储库的源URL更改为指向另一个(可能是空的)存储库(在这种情况下git不会使remotes / origin / *分支无效)。然后你推了,git在另一边没有发现任何提交,所以它必须推动每个提交开发。

I've just tested with Bitbucket HTTPS transport: simple "new branch" push transfers about 200 bytes (see the POST git-receive-pack line):

我刚刚使用Bitbucket HTTPS传输测试:简单的“新分支”推送传输大约200字节(请参阅POST git-receive-pack行):

$ git checkout -b test
Switched to a new branch 'test'

$ git push --verbose -u origin test
Pushing to https://user@bitbucket.org/user/repo.git
Password for 'https://user@bitbucket.org': 
Total 0 (delta 0), reused 0 (delta 0)
POST git-receive-pack (183 bytes)
remote: 
remote: Create pull request for test:
remote:   https://bitbucket.org/user/repo/pull-requests/new?source=test&t=1
remote: 
To https://user@bitbucket.org/user/repo.git
 * [new branch]      test -> test
Branch test set up to track remote branch test from origin.
updating local tracking ref 'refs/remotes/origin/test'

#2


0  

I think this is the normal behavior of git.

我认为这是git的正常行为。

Imagine that someone who is not synced with distant master branch wants to switch on your branch, which is containing some commits from master that he doesn't have yet.

想象一下,没有与远程主分支同步的人想要打开你的分支,其中包含一些他尚未拥有的来自master的提交。

The way that you thought it works would prevent this user from pulling your branch because he doesn't have the missing commits without synchronizing his local master branch.

你认为它的工作方式会阻止这个用户拉你的分支,因为他没有丢失提交而没有同步他的本地主分支。

As your branch tree contains every commits from the beginning, this issue is not happening and the user can pull your branch anyway.

由于您的分支树从头开始包含每个提交,因此不会发生此问题,并且用户无论如何都可以提取您的分支。

#1


2  

Git does not push everything every time.

Git每次都不会推送所有内容。

Possible explanation for this case: you cloned some repository, then changed your local repository's origin url to point to another (possibly empty) repository (git doesn't invalidate remotes/origin/* branches in this case). Then you pushed, and git found no commits on the other side, so it had to push every commit from develop.

这种情况的可能解释:您克隆了一些存储库,然后将您的本地存储库的源URL更改为指向另一个(可能是空的)存储库(在这种情况下git不会使remotes / origin / *分支无效)。然后你推了,git在另一边没有发现任何提交,所以它必须推动每个提交开发。

I've just tested with Bitbucket HTTPS transport: simple "new branch" push transfers about 200 bytes (see the POST git-receive-pack line):

我刚刚使用Bitbucket HTTPS传输测试:简单的“新分支”推送传输大约200字节(请参阅POST git-receive-pack行):

$ git checkout -b test
Switched to a new branch 'test'

$ git push --verbose -u origin test
Pushing to https://user@bitbucket.org/user/repo.git
Password for 'https://user@bitbucket.org': 
Total 0 (delta 0), reused 0 (delta 0)
POST git-receive-pack (183 bytes)
remote: 
remote: Create pull request for test:
remote:   https://bitbucket.org/user/repo/pull-requests/new?source=test&t=1
remote: 
To https://user@bitbucket.org/user/repo.git
 * [new branch]      test -> test
Branch test set up to track remote branch test from origin.
updating local tracking ref 'refs/remotes/origin/test'

#2


0  

I think this is the normal behavior of git.

我认为这是git的正常行为。

Imagine that someone who is not synced with distant master branch wants to switch on your branch, which is containing some commits from master that he doesn't have yet.

想象一下,没有与远程主分支同步的人想要打开你的分支,其中包含一些他尚未拥有的来自master的提交。

The way that you thought it works would prevent this user from pulling your branch because he doesn't have the missing commits without synchronizing his local master branch.

你认为它的工作方式会阻止这个用户拉你的分支,因为他没有丢失提交而没有同步他的本地主分支。

As your branch tree contains every commits from the beginning, this issue is not happening and the user can pull your branch anyway.

由于您的分支树从头开始包含每个提交,因此不会发生此问题,并且用户无论如何都可以提取您的分支。