Reputation: 18066
I'm in a situation with git where I'm managing config-in-code for a website.
Before I'm ready to deploy, I want to check my config directory against a fresh config-in-code export from the live site. I want to confirm that I see the changes from new features, but don't see any deletion or overwriting of features that we want to keep, made on the live site during development of the new features.
So when I do the export in my integration branch, I will see a git status
something like this:
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
I want to get rid of the deleted
changes, but keep all of the modified
changes, so that I can inspect the modifications individually. Any file that's been deleted in a fresh config export from the live site into integration is simply a newly-developed feature that hasn't been deployed to production yet. However, a modification to a config file may trip up a dev who wasn't careful about staying up to date with config during development.
This is all before a commit. How can I undo all of the file deletions, preferably with a single command, while maintain all of the changes? Of course, I can do git checkout fileA
one-by-one, but I wonder if there is a faster way. Tab-completion can't work here, because bash can't see the file in the directory, since its deleted.
Upvotes: 1
Views: 60
Reputation: 8149
Maybe try this instead: (I used Cygwin for this)
git status : I deleted a couple files and modified two files
$ 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")
Run This cmd: Will give you all the files that had a deleted: annotation from git status
git status | grep 'deleted' | awk '{print $2}' | xargs
site/index.html site/js/lib/backbone-min.js site/js/lib/underscore-min.js
Copy the result of that line, then type git checkout -- <copied_value>:
$ git checkout -- site/index.html site/js/lib/backbone-min.js site/js/lib/underscore-min.js
Result: Appears to have reverted any deleted files
$ 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")
Upvotes: 1