threads / discuss / 28559

Unable to remove a file

Subject: Unable to remove a file

## tl;dr

8 messages between Oct 3, 2011 and Oct 4, 2011.

replies: 7people: 4as markdown or json

robert mena· Oct 3, 2011, 14:21 UTC · lore
Hi,

I had a file called \ under a directory scripts. I've removed, committed, pushed to the server BUT my windows clients when they try to clone I stop because of this.

Don't ask me why and it is probably windows/the IDE fault but I have to solve it.

I found the command filter but it is not working.

git filter-branch --index-filter 'git rm --cached scripts/\\' HEAD Rewrite b75a1a3af45a4d82fcfe7a6148fc4d6e1c55ee91 (1/48)rm 'scripts/\' Rewrite 8a32d6194e9c46dc0f1ce60a2245fcbcd7c12d00 (2/48)rm 'scripts/\' Rewrite 892bba8bd7563186d7b1c493cf05d8823cfe2f7b (3/48)rm 'scripts/\' Rewrite 0be74d8143f670b08806510dd09cf77029f57bcb (4/48)rm 'scripts/\' Rewrite ec7e45a5d8100b7a1e49ca8d0cf5ec5d638f2dd7 (5/48)rm 'scripts/\' Rewrite c9dde5bf86391a66f80dc86bcc3078c78866b5da (6/48)rm 'scripts/\' Rewrite 499be785b2538a1d6b382e1a0d6e9bdc8a771a76 (7/48)rm 'scripts/\' Rewrite 327ac340d4dee02bc2bfed07bd94df5f87b8036c (8/48)rm 'scripts/\' Rewrite 5ae256edce2959585b2819c4d6d0d4704b02984a (9/48)rm 'scripts/\' Rewrite 3811ef08c5a2be9f4f049c50caf501944483ec72 (10/48)rm 'scripts/\' Rewrite 52b3de12d3cde4f6bb920d335fe8629d368d965b (11/48)rm 'scripts/\' Rewrite ff115cd8f3213d8218d369361d5ee77010081c22 (12/48)rm 'scripts/\' Rewrite d28c02b462e8ee70c6d516d7d2c6754b82bfc80e (13/48)rm 'scripts/\' Rewrite 173aecfa81f64644747934f815befb8f83daf6ce (14/48)rm 'scripts/\' Rewrite d4649a98584c25c1c8d52adbd49d822c961dc7cb (15/48)rm 'scripts/\' Rewrite d026354566abc0d135cdd3838fa96055baa29a03 (16/48)rm 'scripts/\' Rewrite 9f7869cf30bc0c04e072859bfbc1325758a5e893 (17/48)rm 'scripts/\' Rewrite 6058b6d0b783cd290ce78e344f442d161989b72d (18/48)rm 'scripts/\' Rewrite 7f7842d461a645223e39d5b6c451ec8b3e8f89a4 (19/48)rm 'scripts/\' Rewrite 11f9ad3c22746e4fddb407790eb0db4db709902d (20/48)fatal: pathspec 'scripts/\' did not match any files index filter failed: git rm --cached scripts/\

How can I really delete this without having to start from scratch? I won't hold my breath for windows or even the IDE's to detect this and solve it.

Andreas Schwab· Oct 3, 2011, 16:04 UTC · re: robert mena · lore

Re: Unable to remove a file

robert mena <robert.mena@gmail.com> writes:
> I found the command filter but it is not working.
>
> git filter-branch --index-filter 'git rm --cached scripts/\\' HEAD
$ git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached scripts/\\' HEAD
Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
robert mena· Oct 3, 2011, 20:57 UTC · re: Andreas Schwab · lore

Re: Unable to remove a file

Thanks.
It accepted the command but rejected my push.
git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached
scripts/\\' HEAD
Rewrite 5ac83187fa298add60cf81fd1d54b194da7ae783 (57/57)
Ref 'refs/heads/master' was rewritten
git push
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@myserver:repository'
Should I do anything special?
On Mon, Oct 3, 2011 at 12:04 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
Show 15 quoted lines
> robert mena <robert.mena@gmail.com> writes:
>
>> I found the command filter but it is not working.
>>
>> git filter-branch --index-filter 'git rm --cached scripts/\\' HEAD
>
> $ git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached scripts/\\' HEAD
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>
Zbigniew Jędrzejewski-Szmek· Oct 4, 2011, 07:57 UTC · re: robert mena · lore

Re: Unable to remove a file

On 10/03/2011 10:57 PM, robert mena wrote:
Show 13 quoted lines
> Thanks.
>
> It accepted the command but rejected my push.
>
> git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached
> scripts/\\' HEAD
> Rewrite 5ac83187fa298add60cf81fd1d54b194da7ae783 (57/57)
> Ref 'refs/heads/master' was rewritten
> git push
>   ! [rejected]        master ->  master (non-fast-forward)
> error: failed to push some refs to 'git@myserver:repository'
>
> Should I do anything special?
git push -f
Zbyszek
Show 22 quoted lines
>
> On Mon, Oct 3, 2011 at 12:04 PM, Andreas Schwab<schwab@linux-m68k.org>  wrote:
>> robert mena<robert.mena@gmail.com>  writes:
>>
>>> I found the command filter but it is not working.
>>>
>>> git filter-branch --index-filter 'git rm --cached scripts/\\' HEAD
>>
>> $ git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached scripts/\\' HEAD
>>
>> Andreas.
>>
>> --
>> Andreas Schwab, schwab@linux-m68k.org
>> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
>> "And now for something completely different."
>>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
John Szakmeister· Oct 4, 2011, 10:24 UTC · re: Zbigniew Jędrzejewski-Szmek · lore

Re: Unable to remove a file

2011/10/4 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>: [snip]

Show 11 quoted lines
>> git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached
>> scripts/\\' HEAD
>> Rewrite 5ac83187fa298add60cf81fd1d54b194da7ae783 (57/57)
>> Ref 'refs/heads/master' was rewritten
>> git push
>>  ! [rejected]        master ->  master (non-fast-forward)
>> error: failed to push some refs to 'git@myserver:repository'
>>
>> Should I do anything special?
>
> git push -f

I assume you understand that you're rewriting history Robert, and that has some consequences? You're master branch is now divergent, since the commit ids changed.

-John
robert mena· Oct 4, 2011, 11:36 UTC · re: John Szakmeister · lore

Re: Unable to remove a file

Hi John,

I understand that. For the other that have cloned the repository in the past (no one has committed anything locally) is there any special procedure to be performed or a simply git fetch/pull will make their local repositories in sync?

2011/10/4 John Szakmeister <john@szakmeister.net>:
Show 20 quoted lines
> 2011/10/4 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>:
> [snip]
>>> git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached
>>> scripts/\\' HEAD
>>> Rewrite 5ac83187fa298add60cf81fd1d54b194da7ae783 (57/57)
>>> Ref 'refs/heads/master' was rewritten
>>> git push
>>>  ! [rejected]        master ->  master (non-fast-forward)
>>> error: failed to push some refs to 'git@myserver:repository'
>>>
>>> Should I do anything special?
>>
>> git push -f
>
> I assume you understand that you're rewriting history Robert, and that
> has some consequences?  You're master branch is now divergent, since
> the commit ids changed.
>
> -John
>
Zbigniew Jędrzejewski-Szmek· Oct 4, 2011, 14:08 UTC · re: robert mena · lore

Re: Unable to remove a file

On 10/04/2011 01:36 PM, robert mena wrote:
Show 6 quoted lines
> Hi John,
>
> I understand that.   For the other that have cloned the repository in
> the past (no one has committed anything locally) is there any special
> procedure to be performed or a simply git fetch/pull will make their
> local repositories in sync?

git fetch updates the remote references, always. If the remote is rebased, as in this case, the only difference is that git fetch's message will be a little bit different.

git pull cannot be used in this case! It would "merge" the old history with the new rewritten history... One should do 'git fetch' and then 'git reset --hard origin/master' or something like that.

- Zbyszek

Show 22 quoted lines
> 2011/10/4 John Szakmeister<john@szakmeister.net>:
>> 2011/10/4 Zbigniew Jędrzejewski-Szmek<zbyszek@in.waw.pl>:
>> [snip]
>>>> git filter-branch --index-filter 'git rm -q --ignore-unmatch --cached
>>>> scripts/\\' HEAD
>>>> Rewrite 5ac83187fa298add60cf81fd1d54b194da7ae783 (57/57)
>>>> Ref 'refs/heads/master' was rewritten
>>>> git push
>>>>   ! [rejected]        master ->    master (non-fast-forward)
>>>> error: failed to push some refs to 'git@myserver:repository'
>>>>
>>>> Should I do anything special?
>>>
>>> git push -f
>>
>> I assume you understand that you're rewriting history Robert, and that
>> has some consequences?  You're master branch is now divergent, since
>> the commit ids changed.
>>
>> -John
>>
>
Andreas Schwab· Oct 4, 2011, 14:50 UTC · re: Zbigniew Jędrzejewski-Szmek · lore

Re: Unable to remove a file

Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> writes:
> git fetch updates the remote references, always.
Only if the refspec starts with '+'.
Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

← back to recent threads