2

Alright, apologies for a mouthful of a question. What I'm asking is basically this:

Say I have this git structure in a repo:

branch:         D--E--F  
               /
Master: A--B--C

If I committed a very large binary in D, but then deleted it through another commit E, from what I understand of how Git works, this large binary will still be in the repo history and will be present in storage when someone else clones the repository or tries to work with this branch.

My question is, what happens if at this point I do a squash and merge to Master through GitHub then delete the branch? Now all the changes are squashed into one merge commit into Master. Because the large binary was added then removed, I believe it should not show up in this merge commit on Master at all, and therefore other devs working with Master won't have to worry about this cost. But I need to know for sure.

Also, since the branch was deleted, is there some sort of garbage collection in place that will automatically clean the repository of this large binary at some point in the future?

Essentially I want to know if it's alright to commit a large binary to my branch for testing without incurring costs for everyone down the line with this repository.

aschultz
  • 1,658
  • 3
  • 20
  • 30
NKJo28
  • 373
  • 3
  • 11

1 Answers1

1

I do a squash and merge to Master through GitHub then delete the branch?

That should work, provided you do that on GitHub itself, with a squash commit (or in your local clone repo, but you need to push both the merge commit, and the branch deletion)

I want to know if its alright to commit a large binary to my branch for testing without incurring costs for everyone down the line with this repository.

Since that large binary won't be pushed on GitHub at all... you could simply keep it local, and add it to your .gitignore: it won't be committed.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for the answer. I will be doing the squash and merge through GitHub itself, then also deleting the branch there. Because I am trying to test a system, I have to commit the large binary to my branch then push it to the remote repository. So it's not just in local. Is this still fine? Like once I revert the commit and merge to master then delete this branch can I safely stop worrying about the cost this would incur? – NKJo28 Aug 15 '19 at 07:19
  • @NKJo28 Then it would be best to push it to a fork of your original repository, and make your system use that fork for the test. That way, your binary can remain as long as you need to, since the developers won't clone that fork. – VonC Aug 15 '19 at 07:25
  • That's a good suggestion! I know about forks but didn't consider trying it for this purpose. I will actually do that. But, just for the sake of a complete answer, if I did this to a branch in my original repository then squashed and merged to Master through GitHub. It would still have no effect once I deleted the branch afterwards right? – NKJo28 Aug 15 '19 at 07:33
  • @NKJo28 True, that would work. I only suggested fork because that allows for keep dev and test separate. With your workflow, that is a period of time (before you squash and delete the branch) where a clone/fetch would still get the large binary. – VonC Aug 15 '19 at 07:35