How to git reset –hard everything but 4 files

As you described the problem, it doesn’t look like you want do reset. The simplest thing for this is:

git add app/models/a.rb app/views/a/index.html.rb config/foo.rb config/bar.rb
git checkout .

so, it adds your 4 files into the index, and checks out clean versions (i.e. discards changes) for other files.

I assume you have not staged (git add) modified files before (you should then unstage it using reset).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)