Remove refs/original/heads/master from git repo after filter-branch –tree-filter?

I had the same question as asked here: New git repository in root directory to subsume an exist repository in a sub-directory

I followed this answer here: New git repository in root directory to subsume an exist repository in a sub-directory

  • GitX-L: missing object 0000000000000000000000000000000000000000
  • Why is merge-based SCM better than a lock-based system?
  • svn to git migration: incomplete history
  • Hosting git projects on my own website
  • How to upgrade Git on windows?
  • Need different .htaccess for staging and live site from Git repo
  • Now, gitk --all shows two histories: one culminating in the current master, and one named original/refs/heads/master.

    I don’t know what this second history is, or how to remove it from the repo. I don’t need two histories in my repository.

    How do I get rid of it?

    To reproduce yourself:

    mkdir -p project-root/path/to/module
    cd project-root/path/to/module
    mkdir dir1 dir2 dir3 
    for dir in * ; do touch $dir/source-file-$dir.py ; done
    git init
    git add .
    git commit -m 'Initial commit'
    

    Now we have the original poster’s problem. Let’s move the root of the git repo to project-root using the answer linked above:

    git filter-branch --tree-filter 'mkdir -p path/to/module ; git mv dir1 dir2 dir3 path/to/module' HEAD
    rm -rf path
    cd ../../../ # Now PWD is project-root
    mv path/to/module/.git .
    git reset --hard
    

    Now, see my current problem:

    gitk --all &
    git show-ref
    

    How do I get rid of refs/original/heads/master and all associated history?

  • Git Pull Windows Azure Website
  • nicely display file rename history in git log
  • How can I store keychain credentials for multiple Github accounts?
  • How do you send code review requests with git when devs do not have public work repositories?
  • git add . does not add to the stage to commit
  • Git: ignore a file from a subtree, but track it locally and push it to a remote production
  • 2 Solutions collect form web for “Remove refs/original/heads/master from git repo after filter-branch –tree-filter?”

    refs/original/* is there as a backup, in case you mess up your filter-branch. Believe me, it’s a really good idea.

    Once you’ve inspected the results, and you’re very confident that you have what you want, you can remove the backed up ref:

    git update-ref -d refs/original/refs/heads/master
    

    or if you did this to many refs, and you want to wipe it all out:

    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
    

    (That’s taken directly from the filter-branch manpage.)

    This doesn’t apply to you, but to others who may find this: If you do a filter-branch which removes content taking up significant disk space, you might also want to run git reflog expire --expire=now --all and git gc --prune=now to expire your reflogs and delete the now-unused objects. (Warning: completely, totally irreversible. Be very sure before you do it.)

    And if you’re in Windows PowerShell:

    git for-each-ref --format="%(refname)" refs/original/ | foreach-object -process { git update-ref -d $_ }
    
    Git Baby is a git and github fan, let's start git clone.