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

标签 git bitbucket git-branch git-push

我从 master 创建了一个新分支 develop。然后我使用 develop 分支中的 git push -u origindevelop 将新分支推送到远程。此命令花费了太多时间来推送新的 develop 分支。输出为:

$ 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://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d56535245454e7d5f54495f485e56584913524f5a" rel="noreferrer noopener nofollow">[email protected]</a>/scupids/supertext.git
 * [new branch]      develop -> develop
Branch develop set up to track remote branch develop from origin.
$

从输出来看,它似乎再次 push 了一切。它推送了大约 40 MiB 的数据。

仅供引用,源托管在 Bitbucket 上。

以下是日志命令的输出:

$ 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
.
.
.

我不明白为什么会发生这种情况?

最佳答案

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

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

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

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

$ git push --verbose -u origin test
Pushing to https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c1b4b2a4b381a3a8b5a3b4a2aaa4b5efaeb3a6" rel="noreferrer noopener nofollow">[email protected]</a>/user/repo.git
Password for 'https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3a6a0b6a193b1baa7b1a6b0b8b6a7fdbca1b4" rel="noreferrer noopener nofollow">[email protected]</a>': 
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://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="087d7b6d7a486a617c6a7d6b636d7c26677a6f" rel="noreferrer noopener nofollow">[email protected]</a>/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'

关于git - 将新分支推送到远程再次推送所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32655999/

相关文章:

git - 如何组织具有 vendor 依赖项的 Go 项目?

git - 用户名或密码无效。位桶

git - 用于 ssh 的 git/stash 上的公钥身份验证不起作用

git - 如何将 Accurev 导出到另一个 VCS?

bitbucket - Snyk 如何设置自动拉取请求的审阅者(Bitbucket Cloud)

git - 如何清理分支列表?

Git "error: The branch ' x' 未完全 merge "

git - 将一个 Git 存储库拆分为多个 - 分支成为分支

git - 获取 Git 中的远程分支总数

git - 使用访问 key 从 Bitbucket Repo 的下载部分下载文件