列表文件未更改超过1个月(List files not changed for more than 1 month)
我正在尝试查找过去X个月未更改的文件,因此我可以删除它们或将它们移动到其他仓库(如果有意义的话)。
我知道我可以列出过去10天内更改的文件,例如,执行以下操作:
$ git log --pretty="format:" --since="2 days ago" --name-only | sort | uniq
到目前为止,我必须做的最好的想法是列出所有已添加的文件,然后在过去的X个月中更改所有文件,最后区分2个列表:
$ git log --pretty="format:" --since="1 year ago" --name-only | sort | uniq > 1_year $ git log --pretty="format:" --name-only | sort | uniq > all $ diff 1_year all
问题是:这可能是不对的,因为有些文件被删除了,其他文件被移动/重命名/ etcl ...
有什么办法可以从git命令行获取这样的列表吗?
I'm trying to find files that were not changed in the last X months, so I can maybe delete them or move them to other repo (if it makes sense).
I know I can list the files changed in the last 10 days, for example, doing something like this:
$ git log --pretty="format:" --since="2 days ago" --name-only | sort | uniq
So far, the best idea I have to do what I want would be to list all files ever added, and then all files changed in the last X months, and finally diff the 2 lists:
$ git log --pretty="format:" --since="1 year ago" --name-only | sort | uniq > 1_year $ git log --pretty="format:" --name-only | sort | uniq > all $ diff 1_year all
Problem is: this probably ain't right, since some files were deleted, others moved/renamed/etcl...
Is there any way I can get such list from git command line?
原文:https://stackoverflow.com/questions/34026103
最满意答案
你可以使用
2D
扩展范围数组作为与索引数组index
的形状对齐的第一个轴,因此使用advanced-indexing
,如下所示 -B = A[np.arange(N)[:,None], np.arange(M), index]
You could use
2D
extended range array for the first axis that aligns with the shape of the indexing arrayindex
and hence useadvanced-indexing
, like so -B = A[np.arange(N)[:,None], np.arange(M), index]
相关问答
更多-
已经有一种用于从现有值计算新值的函数 - 函数。 假设我们有一个索引到结构中的函数,我们可以使用它来将结构应用到结构中。 (!!!) = flip ($) infixr 2 !!! 如果我们有一个索引结构的函数和另一个索引任何嵌套结构的函数,我们可以通过在结构上fmap第二个函数,然后应用outer函数来将它们组合在一起。 (!.) :: Functor f => (f b -> g c) -> (a -> b) -> f a -> g c t !. f = t . fmap f infixr 5 ! ...
-
看起来在复制代码时会出现一些错误。 但我怀疑索引存在一个已知问题: In [73]: a=np.zeros((2,3,4)); b=np.ones((3,4)); I=np.array([0,1]) 让I 2元素。 索引b给出预期的(3,2)形状。 切片中有3行, I索引中有2列 In [74]: b[:,I].shape Out[74]: (3, 2) 但是对于3d a我们得到了转置。 In [75]: a[0,:,I].shape Out[75]: (2, 3) 并且赋值会产生错误 In [76] ...
-
NumPy数组索引(NumPy array indexing)[2022-04-30]
假设我已经理解了你 - 明确指定你想要的输出通常是一个好主意,因为它并不明显 - 你可以使用numpy.r_ : In [27]: A Out[27]: array([[0, 1, 2, 3, 4, 5, 6], [4, 5, 6, 7, 4, 5, 6]]) In [28]: A[:, [1,3,4,5]] Out[28]: array([[1, 3, 4, 5], [5, 7, 4, 5]]) In [29]: A[:, r_[1, 3:6]] Out[29]: a ... -
数组索引numpy(Array indexing in numpy)[2022-04-16]
In [42]: x[np.arange(x.shape[0])!=1,:,:] Out[42]: array([[[4, 2, 3], [2, 0, 1], [1, 3, 4]], [[2, 4, 1], [0, 2, 2], [4, 0, 0]]]) In [42]: x[np.arange(x.shape[0])!=1,:,:] Out[42]: array([[[4, 2, 3], [2, 0, 1 ... -
numpy直方图索引(numpy histogram indexing)[2022-06-11]
您可以先使用ogrid()高效地获取索引,然后使用nonzero()获取满足条件的索引。 可以使用非零 ()获取索引,如下所示: indexes = numpy.transpose((x**2+y**2+z**2 <= radius**2).nonzero()) # transpose() might be unnecessary: it depends on your needs 使用ogrid ()有效获取索引数组的位置: x, y, z = numpy.ogrid[:100, :100, :100 ... -
您可以使用: n[n[:,0] > 0, :] You can use: n[n[:,0] > 0, :]
-
Numpy中的高级索引(Advanced indexing in Numpy)[2021-10-15]
你可以使用2D扩展范围数组作为与索引数组index的形状对齐的第一个轴,因此使用advanced-indexing ,如下所示 - B = A[np.arange(N)[:,None], np.arange(M), index] You could use 2D extended range array for the first axis that aligns with the shape of the indexing array index and hence use advanced-index ... -
您需要将索引包装在列表中,而不是元组: x[[1,2]] 。 这会触发高级索引 ,NumPy会返回一个新数组,其中包含您编写的索引处的值。 只要有可能,NumPy就会隐含地假设元组的每个元素都索引数组的不同维度。 您的数组有1维,而不是2,因此x[(1,2)]会引发错误。 x[(1,2), :] ,: x[(1,2), :]成功使用2D数组的原因是你明确地告诉NumPy数组有(至少)两个维度并且从前两个轴说出你想要的东西。 索引被解析为2元组((1,2), :)因此(1,2)用于沿第一轴的高级索引。 如果您 ...
-
从一个简单的1d数组开始: In [326]: x=np.arange(10) 这两个表达式做同样的事情 - 从数组中选择3个元素。 我还可以验证它们返回一个副本,其中x[1:4]返回一个视图。 In [327]: x[(1,2,3),] Out[327]: array([1, 2, 3]) In [328]: x[[1,2,3]] Out[328]: array([1, 2, 3]) 但是没有命令,元组会引发错误: In [329]: x[(1,2,3)] ... IndexError: too m ...
-
Numpy Chain Indexing(Numpy Chain Indexing)[2023-06-14]
但为什么这样,数据[bools,2:,0]不起作用? 因为输入是一个2D数组,所以你没有三个维度可以使用: [bools, 2:, 0] 。 要实现您想要的功能,您可以在掩码bools存储与True相对应的索引,然后将其用作整体或从中进行索引的一个元素。 一个样本运行以使事情清楚 - 输入: In [40]: data Out[40]: array([[ 1.02429045, 1.74104271, -0.54634826], [-0.48451969, 0.83455196, 1. ...