{"thread":{"id":"34630","subject":"Repo with only one file","startedAt":"2013-08-07T06:24:40Z","lastAt":"2013-08-09T21:54:36Z","messageCount":11,"participants":["shawn wilson","Johannes Sixt","Phil Hord"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"224732","messageId":"CAH_OBid8SO3ydpjhRHa68s+54CScLh=jactxTQhwQPo-jcnAvA@mail.gmail.com","threadId":"34630","inReplyTo":null,"subject":"Repo with only one file","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2013-08-07T06:24:40Z","receivedAt":"2013-08-07T06:24:40Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"I started writing this script in a repo I have called misc-scripts\nwhere I just keep one off projects and the like (notes, throw away\nscripts, etc). Well, my boss asked me to create a repo for one of\nthese scripts and I'd like to keep the commit history.\n\nOk, so:\n% find -type f ! -iname \"webban.pl\" | while read f; do git\nfilter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\nHEAD ; done\n\nWhich basically did it. But, I've got this one commit that seems to be\norphaned - it doesn't change any files. That is, it shows up in a git\nlog but not a git whatchanged. When I try to rebase -p --onto, I get\ntons of conflicts, git adding blah in every other line of the file and\nafter I totally mess up the repo, that commit is still there. If I do\na git checkout and try to amend the message, I get:\n\n# Not currently on any branch.\n#\n# Initial commit\n#\n# No changes\nYou asked to amend the most recent commit, but doing so would make\nit empty. You can repeat your command with --allow-empty, or you can\nremove the commit entirely with \"git reset HEAD^\".\n\niWhen I do --allow-empty, I can no longer see any other commits.\n\nSo, how do I remove this commit or what is the proper way to get this\none file into a repo with nothing else?\n\nAlso, I sign my commits and would like to keep each commit signed if\nat all possible.\n"},{"id":"224744","messageId":"520224E0.5060206@viscovery.net","threadId":"34630","inReplyTo":"CAH_OBid8SO3ydpjhRHa68s+54CScLh=jactxTQhwQPo-jcnAvA@mail.gmail.com","subject":"Re: Repo with only one file","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-08-07T10:43:44Z","receivedAt":"2013-08-07T10:43:44Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n> these scripts and I'd like to keep the commit history.\n>\n> Ok, so:\n> % find -type f ! -iname \"webban.pl\" | while read f; do git\n> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n> HEAD ; done\n>\n> Which basically did it. But, I've got this one commit that seems to be\n> orphaned - it doesn't change any files.\n\nTry this:\n\n  git filter-branch HEAD -- webban.pl\n\n-- Hannes\n"},{"id":"224769","messageId":"CAH_OBicysTTu9YdHsHz0H6x3umU5va68J3nT1qHA9-CJY9+E=A@mail.gmail.com","threadId":"34630","inReplyTo":"520224E0.5060206@viscovery.net","subject":"Re: Repo with only one file","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2013-08-07T21:07:39Z","receivedAt":"2013-08-07T21:07:39Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n>> these scripts and I'd like to keep the commit history.\n>>\n>> Ok, so:\n>> % find -type f ! -iname \"webban.pl\" | while read f; do git\n>> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n>> HEAD ; done\n>>\n>> Which basically did it. But, I've got this one commit that seems to be\n>> orphaned - it doesn't change any files.\n>\n> Try this:\n>\n>   git filter-branch HEAD -- webban.pl\n>\n\n % git filter-branch HEAD -- webban.pl\nCannot create a new backup.\nA previous backup already exists in refs/original/\nForce overwriting the backup with -f\n % git filter-branch -f HEAD -- webban.pl\nRewrite 1e04b18c256c996312f167be808733bcc755f1e3 (9/9)\nWARNING: Ref 'refs/heads/master' is unchanged\n"},{"id":"224857","messageId":"CABURp0o_07HdB2o0knPABtAiiuHQ6-fYgemvdCYOsdSghO7v1w@mail.gmail.com","threadId":"34630","inReplyTo":"CAH_OBicysTTu9YdHsHz0H6x3umU5va68J3nT1qHA9-CJY9+E=A@mail.gmail.com","subject":"Re: Repo with only one file","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-08-08T21:11:34Z","receivedAt":"2013-08-08T21:11:34Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n>>> these scripts and I'd like to keep the commit history.\n>>>\n>>> Ok, so:\n>>> % find -type f ! -iname \"webban.pl\" | while read f; do git\n>>> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n>>> HEAD ; done\n>>>\n>>> Which basically did it. But, I've got this one commit that seems to be\n>>> orphaned - it doesn't change any files.\n>>\n>> Try this:\n>>\n>>   git filter-branch HEAD -- webban.pl\n>>\n>\n>  % git filter-branch HEAD -- webban.pl\n> Cannot create a new backup.\n> A previous backup already exists in refs/original/\n> Force overwriting the backup with -f\n>  % git filter-branch -f HEAD -- webban.pl\n> Rewrite 1e04b18c256c996312f167be808733bcc755f1e3 (9/9)\n> WARNING: Ref 'refs/heads/master' is unchanged\n\nI think you can ignore the warning.  Maybe you want to create a new\nbranch which only has this file in it now.\n\n   $ git checkout -b webban\n\nPhil\n"},{"id":"224880","messageId":"52048B5B.5060009@viscovery.net","threadId":"34630","inReplyTo":"CABURp0o_07HdB2o0knPABtAiiuHQ6-fYgemvdCYOsdSghO7v1w@mail.gmail.com","subject":"Re: Repo with only one file","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-08-09T06:25:31Z","receivedAt":"2013-08-09T06:25:31Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 8/8/2013 23:11, schrieb Phil Hord:\n> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n>>>> these scripts and I'd like to keep the commit history.\n>>>>\n>>>> Ok, so:\n>>>> % find -type f ! -iname \"webban.pl\" | while read f; do git\n>>>> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n>>>> HEAD ; done\n>>>>\n>>>> Which basically did it. But, I've got this one commit that seems to be\n>>>> orphaned - it doesn't change any files.\n>>>\n>>> Try this:\n>>>\n>>>   git filter-branch HEAD -- webban.pl\n>>>\n>>\n>>  % git filter-branch HEAD -- webban.pl\n>> Cannot create a new backup.\n>> A previous backup already exists in refs/original/\n>> Force overwriting the backup with -f\n>>  % git filter-branch -f HEAD -- webban.pl\n>> Rewrite 1e04b18c256c996312f167be808733bcc755f1e3 (9/9)\n>> WARNING: Ref 'refs/heads/master' is unchanged\n> \n> I think you can ignore the warning.  Maybe you want to create a new\n> branch which only has this file in it now.\n> \n>    $ git checkout -b webban\n\nI'm not sure. On second thought, my suggested command is not sufficient.\nIt does remove the empty commits, but it does not remove the other files.\nSo, Shawn's original filter-branch invocations are still needed.\n\n-- Hannes\n"},{"id":"224883","messageId":"CAH_OBicF3xn8+MsKH0nTg-HnPg58T-TWHW20r7GqXOm3Nbutfg@mail.gmail.com","threadId":"34630","inReplyTo":"52048B5B.5060009@viscovery.net","subject":"Re: Repo with only one file","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2013-08-09T06:33:53Z","receivedAt":"2013-08-09T06:33:53Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Fri, Aug 9, 2013 at 2:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 8/8/2013 23:11, schrieb Phil Hord:\n>> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n>>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n>>>>> these scripts and I'd like to keep the commit history.\n>>>>>\n>>>>> Ok, so:\n>>>>> % find -type f ! -iname \"webban.pl\" | while read f; do git\n>>>>> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n>>>>> HEAD ; done\n>>>>>\n\n> I'm not sure. On second thought, my suggested command is not sufficient.\n> It does remove the empty commits, but it does not remove the other files.\n> So, Shawn's original filter-branch invocations are still needed.\n>\n\nYeah, I have tried this and haven't gotten any closer. I can either\nremove all of the history or that one commit that has nothing to do\nwith my file is there. This is also reproducable in a new repo.\n\nIs this a bug with filter-branch or git? This doesn't seem like a\nfeature (or how things should act).\n"},{"id":"224884","messageId":"52049121.2080604@viscovery.net","threadId":"34630","inReplyTo":"CAH_OBicF3xn8+MsKH0nTg-HnPg58T-TWHW20r7GqXOm3Nbutfg@mail.gmail.com","subject":"Re: Repo with only one file","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-08-09T06:50:09Z","receivedAt":"2013-08-09T06:50:09Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 8/9/2013 8:33, schrieb shawn wilson:\n> On Fri, Aug 9, 2013 at 2:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>> Am 8/8/2013 23:11, schrieb Phil Hord:\n>>> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n>>>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n>>>>>> these scripts and I'd like to keep the commit history.\n>>>>>>\n>>>>>> Ok, so:\n>>>>>> % find -type f ! -iname \"webban.pl\" | while read f; do git\n>>>>>> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n>>>>>> HEAD ; done\n>>>>>>\n> \n>> I'm not sure. On second thought, my suggested command is not sufficient.\n>> It does remove the empty commits, but it does not remove the other files.\n>> So, Shawn's original filter-branch invocations are still needed.\n>>\n> \n> Yeah, I have tried this and haven't gotten any closer. I can either\n> remove all of the history or that one commit that has nothing to do\n> with my file is there. This is also reproducable in a new repo.\n> \n> Is this a bug with filter-branch or git? This doesn't seem like a\n> feature (or how things should act).\n\nLet's check: After running your command above to remove other files, does\nthe command\n\n   git filter-branch -f HEAD webban.pl\n\nremove the empty commit (if necessary, replace HEAD by the branch name\nthat you are interested in)?\n\n-- Hannes\n"},{"id":"224889","messageId":"CAH_OBifYFyVVo_OEfniWJE=0peX+UPLkRznqyQzvO4gGGLu_tQ@mail.gmail.com","threadId":"34630","inReplyTo":"52049121.2080604@viscovery.net","subject":"Re: Repo with only one file","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2013-08-09T10:03:07Z","receivedAt":"2013-08-09T10:03:07Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Fri, Aug 9, 2013 at 2:50 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 8/9/2013 8:33, schrieb shawn wilson:\n>> On Fri, Aug 9, 2013 at 2:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>> Am 8/8/2013 23:11, schrieb Phil Hord:\n>>>> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n>>>>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>>>>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of\n>>>>>>> these scripts and I'd like to keep the commit history.\n>>>>>>>\n>>>>>>> Ok, so:\n>>>>>>> % find -type f ! -iname \"webban.pl\" | while read f; do git\n>>>>>>> filter-branch -f --index-filter \"git rm --cached --ignore-unmatch $f\"\n>>>>>>> HEAD ; done\n>>>>>>>\n>>\n>>> I'm not sure. On second thought, my suggested command is not sufficient.\n>>> It does remove the empty commits, but it does not remove the other files.\n>>> So, Shawn's original filter-branch invocations are still needed.\n>>>\n>>\n>> Yeah, I have tried this and haven't gotten any closer. I can either\n>> remove all of the history or that one commit that has nothing to do\n>> with my file is there. This is also reproducable in a new repo.\n>>\n>> Is this a bug with filter-branch or git? This doesn't seem like a\n>> feature (or how things should act).\n>\n> Let's check: After running your command above to remove other files, does\n> the command\n>\n>    git filter-branch -f HEAD webban.pl\n>\n\nAhha, no but:\ngit filter-branch -f HEAD -- webban.pl\ndid\n\nThanks.\n\nThe question still stands though - why is that unassociated commit left there?\n"},{"id":"224890","messageId":"5204C546.1030502@viscovery.net","threadId":"34630","inReplyTo":"CAH_OBifYFyVVo_OEfniWJE=0peX+UPLkRznqyQzvO4gGGLu_tQ@mail.gmail.com","subject":"Re: Repo with only one file","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2013-08-09T10:32:38Z","receivedAt":"2013-08-09T10:32:38Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 8/9/2013 12:03, schrieb shawn wilson:\n> The question still stands though - why is that unassociated commit left there?\n\nBecause your command did not remove it. filter-branch does not know that\nit is \"unassociated\" when you ask it to follow all commits beginning at\nHEAD. But when you say 'HEAD -- webban.pl', you ask it to follow only\ncommits that touch webban.pl, which automatically skips that commit.\n\n-- Hannes\n"},{"id":"224908","messageId":"CABURp0p9NGoL=F8-xpicz5J+TmOopYhv-qmxoWagHOcBiKn6=w@mail.gmail.com","threadId":"34630","inReplyTo":"CAH_OBifYFyVVo_OEfniWJE=0peX+UPLkRznqyQzvO4gGGLu_tQ@mail.gmail.com","subject":"Re: Repo with only one file","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-08-09T15:00:25Z","receivedAt":"2013-08-09T15:00:25Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Fri, Aug 9, 2013 at 6:03 AM, shawn wilson <ag4ve.us@gmail.com> wrote:\n> On Fri, Aug 9, 2013 at 2:50 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n>> Let's check: After running your command above to remove other files, does\n>> the command\n>>\n>>    git filter-branch -f HEAD webban.pl\n>>\n>\n> Ahha, no but:\n> git filter-branch -f HEAD -- webban.pl\n> did\n>\n> Thanks.\n>\n> The question still stands though - why is that unassociated commit left there?\n\nMaybe you need  --prune-empty.\n\nPhil\n"},{"id":"224962","messageId":"CAH_OBievQ72gid7OQwCwij3ApjStFScGSQsV_w2Oap24GsHobg@mail.gmail.com","threadId":"34630","inReplyTo":"5204C546.1030502@viscovery.net","subject":"Re: Repo with only one file","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2013-08-09T21:54:36Z","receivedAt":"2013-08-09T21:54:36Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Fri, Aug 9, 2013 at 6:32 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> Am 8/9/2013 12:03, schrieb shawn wilson:\n>> The question still stands though - why is that unassociated commit left there?\n>\n> Because your command did not remove it. filter-branch does not know that\n> it is \"unassociated\" when you ask it to follow all commits beginning at\n> HEAD. But when you say 'HEAD -- webban.pl', you ask it to follow only\n> commits that touch webban.pl, which automatically skips that commit.\n>\n\nI can go with that. However, I don't think that's the end of the story either:\n % du -sh .\n192M    .\n\nSomething has been left behind. What? Or how do I figure that out and remove it?\n"}]}