2

Is there a way to guestimate the size of a git push before actually pushing?

My use case is that a large push size is a good indicator that I likely inadvertenly included some binaries in the staging area (since I usually add with git add . -A). I know I can do a git add . -A -n piped with a grep for the file extensions to watch out for, but a push dry run, so to speak, just to estimate the size would offer some additional reassurance.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
  • 1
    I suggest a better approach would be to make sure you know what you are adding/committing each time. That way, you can be confident when you push that you are only pushing things you actually do want to push. – adrianbanks Oct 28 '12 at 19:41
  • No, don't delete it. It will either remain as is, or get closed as a duplicate if there are enough votes. – adrianbanks Oct 28 '12 at 21:58

1 Answers1

6

You can use just

 git add -A

you don't need the period.

You can also just go ahead and add and then commit everything. Now you can do

git log -1 --stat

this will show you what you are pushing. If you want to know the exact size, you can

git bundle create HEAD^ HEAD

and the file size it produces will be reflective of what will be transmitted if you were to push.

Now you can remove the files that you don't want and

git add -A && git commit --amend --no-edit

which will amend the last commit to include only what you wanted. No edit will reuse your original commit message.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141