Add blob temporarily to a git repository

I need to add some binary files to a Git repository for some time.
(Actually they are ODT documents that I want to consecutively convert to versionable LaTeX source files. I want them in the repo because I work on several computers and also share some work with others).
But I want these binary files to be removed once I don’t need them anymore.
Probably it isn’t a real problem, but for consistency I’d prefer having them purged from the repo.

So what I thought is to create a new branch and add the binary files to it, so all commits with these files are in the context of this single branch.

  • Is there a faster git status -uno?
  • How do I revert `git fetch upstream; git merge upstream/master`?
  • How git clone actually works
  • git rebase ate my commits ! Translate 'git reflog' output for me?
  • What does happen under the hood in a Git checkout?
  • Uncommited changes persist in checkout, generate no warnings
  • If I then delete this branch with git branch -D, do these files disappear or will they still be in the repo as part of its history?

  • How to repair git-svn history when the commit message of a svn commit changes?
  • How to create new project from GIT repo using Eclipse EGit
  • Git master repo branches
  • Fatal: ambiguous argument '<branch_name>': both revision and filename
  • Create commit to overwrite current branch contents with another's
  • Revert commits unique to a branch
  • 3 Solutions collect form web for “Add blob temporarily to a git repository”

    There will still be in the repo for a while.

    First even if the branch is deleted, the commits are still there and referenced in your HEAD reflog (it’s the position on which HEAD was recently). You can see that in .git/logs/HEAD.
    Usually the reflog expires references that are unreachable (from HEAD or any branch) after 30 days. You can force the reflog to expire with git reflog expire.

    Then, once your reflog doesn’t reference to those commits, they won’t be deleted until either git prune or git gc is called. git gc will automatically prune every dangling (meaning that they aren’t referenced anywhere) commit/blob created more than two weeks ago.

    Anyway, in your specific case, if you don’t want those documents in the repo, it might be a good indication that you shouldn’t put them here in the first place and that git isn’t the solution for your problem.

    A solution like dropbox/google drive/etc. would be more appropriate I suppose.

    They will still be part of the hidden history for some time:

    When the branch will be deleted the commits that contain your files will become unreachable, i.e. not reachable when viewing the history. They are in the object store, but none can view them without git sorcery. Also they won’t be retrieved on fetch/pull/clone operations.

    These commits will be purged after some git gc is run, which deletes unreachable commits older than 2 weeks.

    I tried out using the first comment to the original question, and I’d like to share the results of my tests.

    If you save OpenOffice documents as “Flat XML” you get a diffable file format that can be used in Git.
    While this works it is far from perfect because there is quite some overhead that isn’t ‘content’ but configuration info like timestamps, viewport info and things like visible buttons or their state.
    Much from this also goes into the commits.
    This is the diff from inserting one paragraph into an empty document:

    diff --git a/Test2.fodt b/Test2.fodt
    index 02a528a..bec4f67 100644
    --- a/Test2.fodt
    +++ b/Test2.fodt
    @@ -1,7 +1,7 @@
     <?xml version="1.0" encoding="UTF-8"?>
     <office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="" xmlns:dc="" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="" xmlns:ooow="" xmlns:oooc="" xmlns:dom="" xmlns:xforms="" xmlns:xsd="" xmlns:xsi="" xmlns:rpt="" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="" xmlns:grddl="" xmlns:officeooo="" xmlns:tableooo="" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
    - <office:meta><meta:creation-date>2013-02-26T08:36:00</meta:creation-date><meta:generator>LibreOffice/3.6$Linux_x86 LibreOffice_project/360m1$Build-2</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="0" meta:word-count="0" meta:character-count="0" meta:non-whitespace-character-count="0"/></office:meta>
    + <office:meta><meta:creation-date>2013-02-26T08:36:00</meta:creation-date><meta:generator>LibreOffice/3.6$Linux_x86 LibreOffice_project/360m1$Build-2</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="2" meta:character-count="13" meta:non-whitespace-character-count="12"/><dc:date>2013-02-26T08:37:13</dc:date><meta:editing-duration>P0D</meta:editing-duration><meta:editing-cycles>1</meta:editing-cycles></office:meta>
       <config:config-item-set config:name="ooo:view-settings">
        <config:config-item config:name="ViewAreaTop" config:type="int">0</config:config-item>
    @@ -14,7 +14,7 @@
          <config:config-item config:name="ViewId" config:type="string">view2</config:config-item>
          <config:config-item config:name="ViewLeft" config:type="int">6158</config:config-item>
    -     <config:config-item config:name="ViewTop" config:type="int">2501</config:config-item>
    +     <config:config-item config:name="ViewTop" config:type="int">2988</config:config-item>
          <config:config-item config:name="VisibleLeft" config:type="int">0</config:config-item>
          <config:config-item config:name="VisibleTop" config:type="int">0</config:config-item>
          <config:config-item config:name="VisibleRight" config:type="int">29314</config:config-item>
    @@ -205,6 +205,12 @@
       <text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
    +  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
    +   <style:text-properties officeooo:paragraph-rsid="0004a3d7"/>
    +  </style:style>
    +  <style:style style:name="T1" style:family="text">
    +   <style:text-properties officeooo:rsid="0004a3d7"/>
    +  </style:style>
       <style:page-layout style:name="pm1">
        <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin="2cm" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
         <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
    @@ -224,7 +230,8 @@
         <text:sequence-decl text:display-outline-level="0" text:name="Text"/>
         <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
    -   <text:p text:style-name="Standard"/>
    +   <text:p text:style-name="P1"><text:span text:style-name="T1">One paragraph</text:span></text:p>
    +   <text:p text:style-name="P1"><text:span text:style-name="T1"/></text:p>
    \ No newline at end of file
    Git Baby is a git and github fan, let's start git clone.