<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: How to truncate git history (sample script included)</title> <atom:link href="https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html/feed" rel="self" type="application/rss+xml" /><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html</link> <description>Tiny bits of bioinformatics, [web-]programming etc</description> <lastBuildDate>Mon, 01 Jan 2024 17:12:20 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>https://wordpress.org/?v=3.8.27</generator> <item><title>By: JT</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-749853</link> <dc:creator><![CDATA[JT]]></dc:creator> <pubDate>Mon, 29 Mar 2021 15:50:54 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-749853</guid> <description><![CDATA[This works, but you will loose all timestamps for commits that are retained.  Seems like the git team should address a real need to perform housekeeping for repos that undergo lots of change over many years.]]></description> <content:encoded><![CDATA[<p>This works, but you will loose all timestamps for commits that are retained.  Seems like the git team should address a real need to perform housekeeping for repos that undergo lots of change over many years.</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-365507</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Tue, 04 Aug 2015 15:58:34 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-365507</guid> <description><![CDATA[Nigel,
I&#039;ve just tested using git 2.4.6 - had no errors.
Check if this command has `master` at the end and completes successfully - looks like you are not switching to the `master` branch for some reason, which then prevents you from deleting the `temp` branch:
&lt;code&gt;git rebase --onto temp $1 master&lt;/code&gt;
If you just ran all the code as a script - try issuing commands one by one, to see if there are any problems reported by the earlier commands.]]></description> <content:encoded><![CDATA[<p>Nigel,</p><p>I&#8217;ve just tested using git 2.4.6 &#8211; had no errors.<br
/> Check if this command has `master` at the end and completes successfully &#8211; looks like you are not switching to the `master` branch for some reason, which then prevents you from deleting the `temp` branch:</p><p><code>git rebase --onto temp $1 master</code></p><p>If you just ran all the code as a script &#8211; try issuing commands one by one, to see if there are any problems reported by the earlier commands.</p> ]]></content:encoded> </item> <item><title>By: Nigel Horne</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-365324</link> <dc:creator><![CDATA[Nigel Horne]]></dc:creator> <pubDate>Mon, 03 Aug 2015 20:03:16 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-365324</guid> <description><![CDATA[It&#039;s a great idea and just what I want, but it fails with this error:
error: Cannot delete the branch &#039;temp&#039; which you are currently on.]]></description> <content:encoded><![CDATA[<p>It&#8217;s a great idea and just what I want, but it fails with this error:</p><p>error: Cannot delete the branch &#8216;temp&#8217; which you are currently on.</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-232485</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Fri, 28 Mar 2014 09:57:05 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-232485</guid> <description><![CDATA[@Cy - thanks, added both.
P.S. Nice email address! :)]]></description> <content:encoded><![CDATA[<p>@Cy &#8211; thanks, added both.</p><p>P.S. Nice email address! <img
src="https://bogdan.org.ua/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p> ]]></content:encoded> </item> <item><title>By: cy</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-232405</link> <dc:creator><![CDATA[cy]]></dc:creator> <pubDate>Fri, 28 Mar 2014 06:31:30 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-232405</guid> <description><![CDATA[Two things to add to that.
&lt;code&gt;git prune --progress
git gc --aggressive&lt;/code&gt;
the last might not be necessary. git prune will delete all the unreffed objects.]]></description> <content:encoded><![CDATA[<p>Two things to add to that.</p><p><code>git prune --progress<br
/> git gc --aggressive</code></p><p>the last might not be necessary. git prune will delete all the unreffed objects.</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-215921</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Tue, 31 Dec 2013 10:24:41 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-215921</guid> <description><![CDATA[LaboDJ, I don&#039;t see any differences to my code in the post...
P.S. I&#039;ve also edited both my post and your comment to properly show double-dashes.]]></description> <content:encoded><![CDATA[<p>LaboDJ, I don&#8217;t see any differences to my code in the post&#8230;</p><p>P.S. I&#8217;ve also edited both my post and your comment to properly show double-dashes.</p> ]]></content:encoded> </item> <item><title>By: LaboDJ</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-215818</link> <dc:creator><![CDATA[LaboDJ]]></dc:creator> <pubDate>Mon, 30 Dec 2013 13:08:06 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-215818</guid> <description><![CDATA[It works modified like so in latest git version:
&lt;code&gt;
#!/bin/bash
git checkout --orphan temp $1
git commit -m &#039;Truncated history&#039;
git rebase --onto temp $1 master
git branch -D temp
&lt;/code&gt;]]></description> <content:encoded><![CDATA[<p>It works modified like so in latest git version:<br
/> <code><br
/> #!/bin/bash<br
/> git checkout --orphan temp $1<br
/> git commit -m 'Truncated history'<br
/> git rebase --onto temp $1 master<br
/> git branch -D temp<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Tom</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-141432</link> <dc:creator><![CDATA[Tom]]></dc:creator> <pubDate>Fri, 07 Sep 2012 16:06:52 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-141432</guid> <description><![CDATA[Based on notes at the bottom of &quot;http://git-scm.com/docs/git-filter-branch&quot;, I tried the technique in the original post above, then cloned into a new repo, then gc pruned, and then it was much smaller.
I haven&#039;t tried the &quot;graft then filter-branch then clone (and prune)&quot; strategy. I presume it would give similar results?
I also haven&#039;t tried the &quot;destructive&quot; reflog shrinking technique mention in the Git docs.]]></description> <content:encoded><![CDATA[<p>Based on notes at the bottom of &#8220;http://git-scm.com/docs/git-filter-branch&#8221;, I tried the technique in the original post above, then cloned into a new repo, then gc pruned, and then it was much smaller.</p><p>I haven&#8217;t tried the &#8220;graft then filter-branch then clone (and prune)&#8221; strategy. I presume it would give similar results?</p><p>I also haven&#8217;t tried the &#8220;destructive&#8221; reflog shrinking technique mention in the Git docs.</p> ]]></content:encoded> </item> <item><title>By: Mikael Lundin</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-141145</link> <dc:creator><![CDATA[Mikael Lundin]]></dc:creator> <pubDate>Sun, 12 Aug 2012 08:37:06 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-141145</guid> <description><![CDATA[Thank you. This helped me a lot. I neeeded to truncate history to get rid of secrets I had stored in the code, as passwords and app keys, before pushing the whole repository to a public github repo.]]></description> <content:encoded><![CDATA[<p>Thank you. This helped me a lot. I neeeded to truncate history to get rid of secrets I had stored in the code, as passwords and app keys, before pushing the whole repository to a public github repo.</p> ]]></content:encoded> </item> <item><title>By: Bogdan</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-141006</link> <dc:creator><![CDATA[Bogdan]]></dc:creator> <pubDate>Fri, 20 Jul 2012 15:21:28 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-141006</guid> <description><![CDATA[If I remember it right, objects with no references to them are cleaned up during garbage collection (`git gc`); maybe there is a need to supply an extra option to gc (like `--prune`?).]]></description> <content:encoded><![CDATA[<p>If I remember it right, objects with no references to them are cleaned up during garbage collection (`git gc`); maybe there is a need to supply an extra option to gc (like `&#8211;prune`?).</p> ]]></content:encoded> </item> <item><title>By: Jimmy Soho</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-140994</link> <dc:creator><![CDATA[Jimmy Soho]]></dc:creator> <pubDate>Thu, 19 Jul 2012 10:51:07 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-140994</guid> <description><![CDATA[This doesn&#039;t really truncate. It detaches all the commits up till &lt;code&gt;refspec&lt;/code&gt;. But the commits remain present in the git tree. Any idea how to delete all the detached objects?]]></description> <content:encoded><![CDATA[<p>This doesn&#8217;t really truncate. It detaches all the commits up till <code>refspec</code>. But the commits remain present in the git tree. Any idea how to delete all the detached objects?</p> ]]></content:encoded> </item> <item><title>By: Sean Flanigan</title><link>https://bogdan.org.ua/2011/03/28/how-to-truncate-git-history-sample-script-included.html#comment-140080</link> <dc:creator><![CDATA[Sean Flanigan]]></dc:creator> <pubDate>Fri, 04 May 2012 05:30:18 +0000</pubDate> <guid
isPermaLink="false">http://bogdan.org.ua/?p=1481#comment-140080</guid> <description><![CDATA[Thanks for the script!
Git 1.7.1 doesn&#039;t support &quot;checkout --orphan&quot;, so I found I had to replace
git checkout --orphan temp $1
with
git checkout $1
git symbolic-ref HEAD refs/heads/temp
which may or may not be correct, but it /seems/ to work.]]></description> <content:encoded><![CDATA[<p>Thanks for the script!</p><p>Git 1.7.1 doesn&#8217;t support &#8220;checkout &#8211;orphan&#8221;, so I found I had to replace<br
/> git checkout &#8211;orphan temp $1<br
/> with<br
/> git checkout $1<br
/> git symbolic-ref HEAD refs/heads/temp</p><p>which may or may not be correct, but it /seems/ to work.</p> ]]></content:encoded> </item> </channel> </rss>