Added a comment: git checkout --orphan

This commit is contained in:
https://www.google.com/accounts/o8/id?id=AItOawln3ckqKx0x_xDZMYwa9Q1bn4I06oWjkog 2013-07-19 17:49:37 +00:00 committed by admin
parent 2fec3de9a4
commit 2961d94fa1

View file

@ -0,0 +1,40 @@
[[!comment format=mdwn
username="https://www.google.com/accounts/o8/id?id=AItOawln3ckqKx0x_xDZMYwa9Q1bn4I06oWjkog"
nickname="Michael"
subject="git checkout --orphan"
date="2013-07-19T17:49:37Z"
content="""
Instead of rebase, --orphan seems to be the right answer for pruning history: create a new git-annex orphan branch and git add and commit the files. So:
<pre><code>
git status
# verify there are no uncommitted or untracked files
# master branch
git branch -m old-master
git checkout --orphan master
git add .
git commit -m 'first commit'
# git annex branch
git branch -m git-annex old-git-annex
git checkout git-annex
git checkout --orphan git-annex
git add .
git commit -m 'first commit'
git checkout master
# at this point, you may want to double-check that everything is still OK
# finally, remove branches and clean up the objects:
git branch -D old-master old-git-annex
git reflog expire --expire=now --all
git prune
git gc
</code></pre>
The repo remains functional and .git is smaller.
"""]]