Note that there are some explanatory texts on larger screens.

plurals
  1. POgit filter-branch led to a disconnected history: how to get rid of the old commits?
    primarykey
    data
    text
    <p>The scenario is the following:</p> <p>I have a big CVS repository that I want to convert to 14 distinct git repositories. The <code>cvs2git</code> part of the process is fine and leads to a big repository repo.git.</p> <p>For each of the 14 git repo, I clone the main repo and I run the following command :</p> <pre><code>git filter-branch -d /tmp/rep --tag-name-filter cat --prune-empty --subdirectory-filter "sub/directory" -- --all </code></pre> <p>However, prior to this command, I have to perform another <code>git filter-branch</code> command for some git repositories because I have to rewrite the commits to move a file from a directory to another. The <code>--tree-filter</code> is the option I use. Here is a example of the command line executed:</p> <pre><code>script_tree_filter="if test -f rep/to/my/file &amp;&amp; test -d another/rep ; then echo Moving my file ; mv rep/to/my/file another/rep; fi" git filter-branch -d /tmp/rep --tag-name-filter cat --prune-empty --tree-filter '$script_tree_filter' -- --all </code></pre> <p>At the end of the process (14500 commits: it takes about 1 hour !) I clean the refs and use <code>git gc</code>:</p> <pre><code>git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d git reflog expire --expire=now --all git gc --prune=now </code></pre> <p>At the end I obtain a repository with a size of 1.2Go (which is still obviously too big), and by looking at the commits, I can see that a lot of old ones are still present. They concern file and directories which should not be here anymore after the <code>--subdirectory-filter</code> command.</p> <p>In the history of the commits, there is a discontinuity between the unwanted commits and the good ones as seen in <code>gitk --all</code>:</p> <p><img src="https://i.stack.imgur.com/JP1FP.png" alt="discontinuity seen in gitk"></p> <p>I am pretty certain that those commits are still present because of the tags on some on them. If this is the case, is it possible to remove those tags without removing the one on the good commits ?</p> <p>If the tags are not the reason, any idea ?</p> <p>For more information, the content of the <code>refs</code> directory (in the git repository obtained by subdirectory-filter) is empty:</p> <pre><code>$ ls -R refs/ refs/: heads original tags refs/heads: refs/original: refs refs/original/refs: heads tags refs/original/refs/heads: refs/original/refs/tags: refs/tags: </code></pre> <p>I've found that the branches and tags are listed in the file <code>packed-refs</code> in the git repository:</p> <pre><code>d0c675d8f198ce08bb68f368b6ca83b5fea70a2b refs/tags/v03-rev-04 95c3f91a4e92e9bd11573ff4bb8ed4b61448d8f7 refs/tags/v03-rev-05 </code></pre> <p>There are 817 tags and 219 branches listed in the file.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload