git -add不适用于通配符 [英] git -add doesn't work with wildcards

查看:139
本文介绍了git -add不适用于通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图添加(编辑:删除操作)这些文件中的文字生成,它不起作用。我使用PowerShell。

I'm trying to add (edit: THE DELETE operation) of these files with the text "generated" in it, and it doesn't work. I'm using PowerShell.

#       deleted:    Apica.WebPerformance.Web.Controllers/SharedController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/SidebarController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/SubscriptionController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/ToolsController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/UnauthorizedController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/UrlCheckController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/UrlCheckWizardController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/UserSessionContextController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/UserSessionContextDataController.generated.cs
#       modified:   Apica.WebPerformance.Web.Controllers/ViewModels/Checks/CheckListViewModel.cs
#       modified:   Apica.WebPerformance.Web.Controllers/ViewModels/Checks/ChecksOverviewViewModel.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/WebSocketCheckWizardController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/WebSocketJmsCheckWizardController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/WidgetsController.generated.cs
#       deleted:    Apica.WebPerformance.Web.Controllers/WizardController.generated.cs
#       modified:   Apica.WebPerformance.Web/Assets/Common/Css/jquery.multiSelect.css
#       modified:   Apica.WebPerformance.Web/Views/Examples/MultiSelect.cshtml
#
C:\git_apica\WebPerformance.Web [ViewModelRefactor +6 ~2 -0 | +0 ~6 -52]> git add *generated.cs
C:\git_apica\WebPerformance.Web [ViewModelRefactor +6 ~2 -0 | +0 ~6 -52]> git add '*generated.cs'
C:\git_apica\WebPerformance.Web [ViewModelRefactor +6 ~2 -0 | +0 ~6 -52]> git add '*generated*'
C:\git_apica\WebPerformance.Web [ViewModelRefactor +6 ~2 -0 | +0 ~6 -52]> git add \*generated.cs
C:\git_apica\WebPerformance.Web [ViewModelRefactor +6 ~2 -0 | +0 ~6 -52]> git add '*generated.cs'
C:\git_apica\WebPerformance.Web [ViewModelRefactor +6 ~2 -0 | +0 ~6 -52]> 

这些命令都不会执行任何操作。然而,它的工作原理是文件。

None of these commands actually stage anything. It works file by file, however.

推荐答案

看起来你的命令有两个小问题。 b

Looks like there are two minor issues with your command


  1. 它看起来像你想要登台的文件是一个从shell位置开始的目录,所以你需要添加一个 * code>。

  2. 您想要删除已删除的文件。有两种方法可以调用 git rm< file name> ,或使用 -u 添加命令。
    来自文档(重点是我的):

  1. It looks like the files you want to stage are a directory down from where the shell is, so you need to add a leading *.
  2. You want to stage files that have been removed. There are two ways to do that calling git rm <file name> in each removed file or using the -u flag of the add command. From documentation (emphasis mine):


-u

--update

只匹配索引中已经跟踪的文件而不是工作树。这意味着它永远不会展示新文件,但它会逐步修改已跟踪文件的新内容,并且如果工作树中的相应文件已被删除,它将从索引中删除文件


git add -u * \ * .generated .cs 应该有效。

这篇关于git -add不适用于通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆