我遇到了git的问题,我正在管理网站的代码配置。
在准备进行部署之前,我想针对我的配置目录进行检查,以从实时站点中导出新的config-in-code。我想确认我看到了新功能的变化,但是没有看到在开发新功能时在实时站点上所做的任何删除或覆盖我们要保留的功能。
因此,当我在集成分支中执行导出时,将看到类似git status
的内容:
modified: core.entity_form_display.node.page.default.yml
modified: core.entity_view_display.node.landing_page.default.yml
modified: core.entity_view_display.node.page.default.yml
modified: core.entity_view_display.node.page.full_width.yml
modified: field.field.node.page.field_another_field
deleted: field.field.node.landing_page.field_social_media_share_image.yml
deleted: field.field.node.page.field_documents.yml
deleted: system.core.config.deal
我想摆脱deleted
的更改,但保留所有modified
的更改,以便我可以单独检查修改。从实时站点以全新配置导出到集成中的所有已删除文件都是简单的新开发功能,尚未部署到生产环境中。但是,对配置文件的修改可能会使开发人员不满意,因为该开发人员在开发过程中不及时了解config。
这一切都在提交之前。在维护所有更改的同时,如何才能撤消所有文件删除操作(最好使用单个命令)?当然,我可以一对一地做git checkout fileA
,但是我想知道是否有更快的方法。制表符补全不能在这里使用,因为bash自删除以来在目录中看不到该文件。
答案 0 :(得分:1)
也许可以试试看:(我为此使用Cygwin )
git status :我删除了几个文件,并修改了两个文件
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: site/index.html
modified: site/js/app.js
deleted: site/js/lib/backbone-min.js
deleted: site/js/lib/underscore-min.js
modified: site/js/views/HandleBarView.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vs/
no changes added to commit (use "git add" and/or "git commit -a")
运行此cmd:将为您提供所有已删除的文件:git状态注释
git status | grep 'deleted' | awk '{print $2}' | xargs
site/index.html site/js/lib/backbone-min.js site/js/lib/underscore-min.js
复制该行的结果,然后输入git checkout-
$ git checkout -- site/index.html site/js/lib/backbone-min.js site/js/lib/underscore-min.js
结果:似乎已还原了所有已删除的文件
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: site/js/app.js
modified: site/js/views/HandleBarView.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vs/
no changes added to commit (use "git add" and/or "git commit -a")