Search code examples
gitdiskspacegit-cherry-pick

Cherry picking commit in git: is large file data duplicated?


I understand that if you cherry pick a commit in git, it creates a new copy of the commit (with new SHA etc).

But internally, if there is a large binary file, is the data duplicated, causing the repo to bloat? Or is it smart enough to understand that it's the same blob?


Solution

  • Git is smart enough to keep using the same object and reference it in the new created commit from your cherry-pick. (Although I somewhat understand your worries about a duplicate copy, since the commit itself isn't just duplicated but recreated.)

    When the file will actually change, then you'll have a new object created, thus increasing the repo.