All of lore.kernel.org
 help / color / mirror / Atom feed
* Repo with only one file
@ 2013-08-07  6:24 shawn wilson
  2013-08-07 10:43 ` Johannes Sixt
  0 siblings, 1 reply; 11+ messages in thread
From: shawn wilson @ 2013-08-07  6:24 UTC (permalink / raw)
  To: Git List

I started writing this script in a repo I have called misc-scripts
where I just keep one off projects and the like (notes, throw away
scripts, etc). Well, my boss asked me to create a repo for one of
these scripts and I'd like to keep the commit history.

Ok, so:
% find -type f ! -iname "webban.pl" | while read f; do git
filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
HEAD ; done

Which basically did it. But, I've got this one commit that seems to be
orphaned - it doesn't change any files. That is, it shows up in a git
log but not a git whatchanged. When I try to rebase -p --onto, I get
tons of conflicts, git adding blah in every other line of the file and
after I totally mess up the repo, that commit is still there. If I do
a git checkout and try to amend the message, I get:

# Not currently on any branch.
#
# Initial commit
#
# No changes
You asked to amend the most recent commit, but doing so would make
it empty. You can repeat your command with --allow-empty, or you can
remove the commit entirely with "git reset HEAD^".

iWhen I do --allow-empty, I can no longer see any other commits.

So, how do I remove this commit or what is the proper way to get this
one file into a repo with nothing else?

Also, I sign my commits and would like to keep each commit signed if
at all possible.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-07  6:24 Repo with only one file shawn wilson
@ 2013-08-07 10:43 ` Johannes Sixt
  2013-08-07 21:07   ` shawn wilson
  0 siblings, 1 reply; 11+ messages in thread
From: Johannes Sixt @ 2013-08-07 10:43 UTC (permalink / raw)
  To: shawn wilson; +Cc: Git List

Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
> these scripts and I'd like to keep the commit history.
>
> Ok, so:
> % find -type f ! -iname "webban.pl" | while read f; do git
> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
> HEAD ; done
>
> Which basically did it. But, I've got this one commit that seems to be
> orphaned - it doesn't change any files.

Try this:

  git filter-branch HEAD -- webban.pl

-- Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-07 10:43 ` Johannes Sixt
@ 2013-08-07 21:07   ` shawn wilson
  2013-08-08 21:11     ` Phil Hord
  0 siblings, 1 reply; 11+ messages in thread
From: shawn wilson @ 2013-08-07 21:07 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Git List

On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
>> these scripts and I'd like to keep the commit history.
>>
>> Ok, so:
>> % find -type f ! -iname "webban.pl" | while read f; do git
>> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
>> HEAD ; done
>>
>> Which basically did it. But, I've got this one commit that seems to be
>> orphaned - it doesn't change any files.
>
> Try this:
>
>   git filter-branch HEAD -- webban.pl
>

 % git filter-branch HEAD -- webban.pl
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f
 % git filter-branch -f HEAD -- webban.pl
Rewrite 1e04b18c256c996312f167be808733bcc755f1e3 (9/9)
WARNING: Ref 'refs/heads/master' is unchanged

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-07 21:07   ` shawn wilson
@ 2013-08-08 21:11     ` Phil Hord
  2013-08-09  6:25       ` Johannes Sixt
  0 siblings, 1 reply; 11+ messages in thread
From: Phil Hord @ 2013-08-08 21:11 UTC (permalink / raw)
  To: shawn wilson; +Cc: Johannes Sixt, Git List

On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
>>> these scripts and I'd like to keep the commit history.
>>>
>>> Ok, so:
>>> % find -type f ! -iname "webban.pl" | while read f; do git
>>> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
>>> HEAD ; done
>>>
>>> Which basically did it. But, I've got this one commit that seems to be
>>> orphaned - it doesn't change any files.
>>
>> Try this:
>>
>>   git filter-branch HEAD -- webban.pl
>>
>
>  % git filter-branch HEAD -- webban.pl
> Cannot create a new backup.
> A previous backup already exists in refs/original/
> Force overwriting the backup with -f
>  % git filter-branch -f HEAD -- webban.pl
> Rewrite 1e04b18c256c996312f167be808733bcc755f1e3 (9/9)
> WARNING: Ref 'refs/heads/master' is unchanged

I think you can ignore the warning.  Maybe you want to create a new
branch which only has this file in it now.

   $ git checkout -b webban

Phil

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-08 21:11     ` Phil Hord
@ 2013-08-09  6:25       ` Johannes Sixt
  2013-08-09  6:33         ` shawn wilson
  0 siblings, 1 reply; 11+ messages in thread
From: Johannes Sixt @ 2013-08-09  6:25 UTC (permalink / raw)
  To: Phil Hord; +Cc: shawn wilson, Git List

Am 8/8/2013 23:11, schrieb Phil Hord:
> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
>>>> these scripts and I'd like to keep the commit history.
>>>>
>>>> Ok, so:
>>>> % find -type f ! -iname "webban.pl" | while read f; do git
>>>> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
>>>> HEAD ; done
>>>>
>>>> Which basically did it. But, I've got this one commit that seems to be
>>>> orphaned - it doesn't change any files.
>>>
>>> Try this:
>>>
>>>   git filter-branch HEAD -- webban.pl
>>>
>>
>>  % git filter-branch HEAD -- webban.pl
>> Cannot create a new backup.
>> A previous backup already exists in refs/original/
>> Force overwriting the backup with -f
>>  % git filter-branch -f HEAD -- webban.pl
>> Rewrite 1e04b18c256c996312f167be808733bcc755f1e3 (9/9)
>> WARNING: Ref 'refs/heads/master' is unchanged
> 
> I think you can ignore the warning.  Maybe you want to create a new
> branch which only has this file in it now.
> 
>    $ git checkout -b webban

I'm not sure. On second thought, my suggested command is not sufficient.
It does remove the empty commits, but it does not remove the other files.
So, Shawn's original filter-branch invocations are still needed.

-- Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-09  6:25       ` Johannes Sixt
@ 2013-08-09  6:33         ` shawn wilson
  2013-08-09  6:50           ` Johannes Sixt
  0 siblings, 1 reply; 11+ messages in thread
From: shawn wilson @ 2013-08-09  6:33 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Phil Hord, Git List

On Fri, Aug 9, 2013 at 2:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 8/8/2013 23:11, schrieb Phil Hord:
>> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
>>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
>>>>> these scripts and I'd like to keep the commit history.
>>>>>
>>>>> Ok, so:
>>>>> % find -type f ! -iname "webban.pl" | while read f; do git
>>>>> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
>>>>> HEAD ; done
>>>>>

> I'm not sure. On second thought, my suggested command is not sufficient.
> It does remove the empty commits, but it does not remove the other files.
> So, Shawn's original filter-branch invocations are still needed.
>

Yeah, I have tried this and haven't gotten any closer. I can either
remove all of the history or that one commit that has nothing to do
with my file is there. This is also reproducable in a new repo.

Is this a bug with filter-branch or git? This doesn't seem like a
feature (or how things should act).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-09  6:33         ` shawn wilson
@ 2013-08-09  6:50           ` Johannes Sixt
  2013-08-09 10:03             ` shawn wilson
  0 siblings, 1 reply; 11+ messages in thread
From: Johannes Sixt @ 2013-08-09  6:50 UTC (permalink / raw)
  To: shawn wilson; +Cc: Phil Hord, Git List

Am 8/9/2013 8:33, schrieb shawn wilson:
> On Fri, Aug 9, 2013 at 2:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>> Am 8/8/2013 23:11, schrieb Phil Hord:
>>> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
>>>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>>>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
>>>>>> these scripts and I'd like to keep the commit history.
>>>>>>
>>>>>> Ok, so:
>>>>>> % find -type f ! -iname "webban.pl" | while read f; do git
>>>>>> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
>>>>>> HEAD ; done
>>>>>>
> 
>> I'm not sure. On second thought, my suggested command is not sufficient.
>> It does remove the empty commits, but it does not remove the other files.
>> So, Shawn's original filter-branch invocations are still needed.
>>
> 
> Yeah, I have tried this and haven't gotten any closer. I can either
> remove all of the history or that one commit that has nothing to do
> with my file is there. This is also reproducable in a new repo.
> 
> Is this a bug with filter-branch or git? This doesn't seem like a
> feature (or how things should act).

Let's check: After running your command above to remove other files, does
the command

   git filter-branch -f HEAD webban.pl

remove the empty commit (if necessary, replace HEAD by the branch name
that you are interested in)?

-- Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-09  6:50           ` Johannes Sixt
@ 2013-08-09 10:03             ` shawn wilson
  2013-08-09 10:32               ` Johannes Sixt
  2013-08-09 15:00               ` Phil Hord
  0 siblings, 2 replies; 11+ messages in thread
From: shawn wilson @ 2013-08-09 10:03 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Phil Hord, Git List

On Fri, Aug 9, 2013 at 2:50 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 8/9/2013 8:33, schrieb shawn wilson:
>> On Fri, Aug 9, 2013 at 2:25 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>>> Am 8/8/2013 23:11, schrieb Phil Hord:
>>>> On Wed, Aug 7, 2013 at 5:07 PM, shawn wilson <ag4ve.us@gmail.com> wrote:
>>>>> On Wed, Aug 7, 2013 at 6:43 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>>>>>> Am 8/7/2013 8:24, schrieb shawn wilson:> ... create a repo for one of
>>>>>>> these scripts and I'd like to keep the commit history.
>>>>>>>
>>>>>>> Ok, so:
>>>>>>> % find -type f ! -iname "webban.pl" | while read f; do git
>>>>>>> filter-branch -f --index-filter "git rm --cached --ignore-unmatch $f"
>>>>>>> HEAD ; done
>>>>>>>
>>
>>> I'm not sure. On second thought, my suggested command is not sufficient.
>>> It does remove the empty commits, but it does not remove the other files.
>>> So, Shawn's original filter-branch invocations are still needed.
>>>
>>
>> Yeah, I have tried this and haven't gotten any closer. I can either
>> remove all of the history or that one commit that has nothing to do
>> with my file is there. This is also reproducable in a new repo.
>>
>> Is this a bug with filter-branch or git? This doesn't seem like a
>> feature (or how things should act).
>
> Let's check: After running your command above to remove other files, does
> the command
>
>    git filter-branch -f HEAD webban.pl
>

Ahha, no but:
git filter-branch -f HEAD -- webban.pl
did

Thanks.

The question still stands though - why is that unassociated commit left there?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-09 10:03             ` shawn wilson
@ 2013-08-09 10:32               ` Johannes Sixt
  2013-08-09 21:54                 ` shawn wilson
  2013-08-09 15:00               ` Phil Hord
  1 sibling, 1 reply; 11+ messages in thread
From: Johannes Sixt @ 2013-08-09 10:32 UTC (permalink / raw)
  To: shawn wilson; +Cc: Phil Hord, Git List

Am 8/9/2013 12:03, schrieb shawn wilson:
> The question still stands though - why is that unassociated commit left there?

Because your command did not remove it. filter-branch does not know that
it is "unassociated" when you ask it to follow all commits beginning at
HEAD. But when you say 'HEAD -- webban.pl', you ask it to follow only
commits that touch webban.pl, which automatically skips that commit.

-- Hannes

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-09 10:03             ` shawn wilson
  2013-08-09 10:32               ` Johannes Sixt
@ 2013-08-09 15:00               ` Phil Hord
  1 sibling, 0 replies; 11+ messages in thread
From: Phil Hord @ 2013-08-09 15:00 UTC (permalink / raw)
  To: shawn wilson; +Cc: Johannes Sixt, Git List

On Fri, Aug 9, 2013 at 6:03 AM, shawn wilson <ag4ve.us@gmail.com> wrote:
> On Fri, Aug 9, 2013 at 2:50 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
>> Let's check: After running your command above to remove other files, does
>> the command
>>
>>    git filter-branch -f HEAD webban.pl
>>
>
> Ahha, no but:
> git filter-branch -f HEAD -- webban.pl
> did
>
> Thanks.
>
> The question still stands though - why is that unassociated commit left there?

Maybe you need  --prune-empty.

Phil

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Repo with only one file
  2013-08-09 10:32               ` Johannes Sixt
@ 2013-08-09 21:54                 ` shawn wilson
  0 siblings, 0 replies; 11+ messages in thread
From: shawn wilson @ 2013-08-09 21:54 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Phil Hord, Git List

On Fri, Aug 9, 2013 at 6:32 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> Am 8/9/2013 12:03, schrieb shawn wilson:
>> The question still stands though - why is that unassociated commit left there?
>
> Because your command did not remove it. filter-branch does not know that
> it is "unassociated" when you ask it to follow all commits beginning at
> HEAD. But when you say 'HEAD -- webban.pl', you ask it to follow only
> commits that touch webban.pl, which automatically skips that commit.
>

I can go with that. However, I don't think that's the end of the story either:
 % du -sh .
192M    .

Something has been left behind. What? Or how do I figure that out and remove it?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-08-09 21:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-07  6:24 Repo with only one file shawn wilson
2013-08-07 10:43 ` Johannes Sixt
2013-08-07 21:07   ` shawn wilson
2013-08-08 21:11     ` Phil Hord
2013-08-09  6:25       ` Johannes Sixt
2013-08-09  6:33         ` shawn wilson
2013-08-09  6:50           ` Johannes Sixt
2013-08-09 10:03             ` shawn wilson
2013-08-09 10:32               ` Johannes Sixt
2013-08-09 21:54                 ` shawn wilson
2013-08-09 15:00               ` Phil Hord

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.