When I do a git status, I see files like this:
modified: dir/A/file.txt modified: dir/B/file.txt modified: dir/C/file.txt modified: dir/D/file.txt
What I want to do is to discard changes to all files EXCEPT for dir/C/file.txt
I want to do something like this:
git checkout -- dir/!C/file.txt
Run a 'git add . ' to add all the files. Then run 'git reset -- xxx/dontcheckmein. txt'.
Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.
The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.
git add dir/C/file.txt # this file will stay modified and staged git checkout .
If you want to unstage the file after that:
git reset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With