あなたは何か誤解があったはずです。 Git pushは、新しいオブジェクトだけを送信します。たとえば、あるファイル(README.txt)を更新し、それを新しいリモートブランチにプッシュする、このシンプルなシーケンスを見てみましょう。
$ git checkout -b new_branch
Branch new_branch set up to track local branch master.
Switched to a new branch 'new_branch'
$ echo "New readme file content" > README.txt
$ g commit -a -m "Commit only on new branch"
[new_branch 8d8f56d] Commit only on new branch
1 file changed, 1 insertion(+), 3 deletions(-)
$ git log --oneline --decorate
8d8f56d (HEAD, new_branch) Commit only on new branch
d101a0e (origin/master, master) Small update
2d02c36 Initial commit
$ git push origin new_branch
Counting objects: 3, done.
Writing objects: 100% (3/3), 283 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To /tmp/myrepo.git/
* [new branch] new_branch -> new_branch
Git pushは3つのオブジェクトのみを送信しました。それらは以下のとおりです。
- テキストを含む新しいBlobオブジェクト:「新しいReadmeファイルの内容」
- (新しいブロブオブジェクトを指す)レポルートディレクトリを表す新しいツリーオブジェクト
- 新しいコミットリモートリポジトリはすでにこれらのコミットを持っていたので、我々は古いオブジェクト2d02c36をコミットすることを
git log
出力
ノートで見ることができたオブジェクト8d8f56dは、d101a0eや木/それらのコミットに関連したブロブは、送信されませんでした。 リポジトリ内に深いディレクトリ構造がある場合は、1つのファイルのみを更新しても、変更されたファイルの親ディレクトリごとに1つずつ、非常に多くの新しいツリーオブジェクトを送信する必要があります。
リモート用の新しいブランチであるため、すべてのファイルが転送されます。 – hjpotter92
コミットではなくブランチをプッシュしました。何を期待していたのですか? –
今すぐ変更して2回目のプッシュを行うと、gitは最新のコミットだけを送信します。 –