Re: git: b1f7154cb125 - main - gitignore: ignore vim swap files & .rej/.orig

From: Renato Botelho <garga_at_FreeBSD.org>
Date: Fri, 11 Feb 2022 15:17:12 UTC
On 11/02/22 12:12, Renato Botelho wrote:
> On 11/02/22 12:11, Renato Botelho wrote:
>> On 11/02/22 12:02, Drew Gallatin wrote:
>>> I think that has the same problem.  Either that, or I'm doing the 
>>> escaping wrong.  Using tcsh:
>>>
>>> <10:01am>beast/gallatin:work1>git clean -ne '\!\*.orig'
>>> Would remove ktrace.out
>>> <10:01am>beast/gallatin:work1>git clean -xn | grep rej
>>> Would remove FreeBSD/sys/dev/mlx5/mlx5_en/en_hw_tls.h.rej
>>
>> -e expects a pattern of files/directories that you don't want to 
>> remove and can be used multiple times.  It worked here on a testing repo:
>>
>> sh-3.2$ git clean -xn
>> Would remove d1/d2/bar.orig
>> Would remove d1/d2/bar.rej
>> Would remove foo.orig
>> Would remove foo.rej
>>
>> sh-3.2$ git clean -xn -e '*.rej'
>> Would remove d1/d2/bar.orig
>> Would remove foo.orig
>>
>> sh-3.2$ git clean -xn -e '*.rej' -e '*.orig'
>> sh-3.2$
>>
> 
> Fat finger here, I was about to say you also can specify what you want 
> to remove using wildcards like:
> 
> sh-3.2$ git clean -xn '*.orig'
> Would remove d1/d2/bar.orig
> Would remove foo.orig
> 
> sh-3.2$ git clean -xn '*.rej'
> Would remove d1/d2/bar.rej
> Would remove foo.rej
> 

And last but not least, if it does what you need, you can create an 
alias to make it simpler:

sh-3.2$ git config --global alias.myclean "clean -xn '*.rej' '*.orig'"
sh-3.2$ git myclean
Would remove d1/d2/bar.orig
Would remove d1/d2/bar.rej
Would remove foo.orig
Would remove foo.rej

-- 
Renato Botelho