With git I would like to add (almost) all the modified files, in practice those marked with the letter M in VScode, but I would like to add exceptions, that is, not to consider one or two files.
Is there a generic way to say to add all the changes except one or two files?
- Yes, add each and every file you actually want to commit.fredrik– fredrik2020-01-10 09:25:32 +00:00Commented Jan 10, 2020 at 9:25
- 1stackoverflow.com/a/51914162/10155936Saurabh P Bhandari– Saurabh P Bhandari2020-01-10 09:31:27 +00:00Commented Jan 10, 2020 at 9:31
- what if there are too many files then it becomes difficult to add individual files then this will be helpfulRadha Manohar– Radha Manohar2020-01-10 09:44:29 +00:00Commented Jan 10, 2020 at 9:44
Add a comment |
2 Answers
You might be better off adding everything then unstaging the ones you don't want :
git add -u git reset -- path/to/file1 path/to/file2 5 Comments
Memmo
Why would you use
git add . instead of git add -u?Radha Manohar
generally
-u is used to detect changed files. Let say you have changed a file and created a new file. git will only recognize the file change but not the new file. by giving -u it recognizes new file entries tooKarnikamit
@Memmo git add . is to add all files including those which are not been tracked, git add -u is to add all the files which are tracked.
Memmo
Exact! It was what I wanted. Edited files only (M in VScode)
Romain Valeri
@Memmo I didn't get that you wanted to (re)add each file, I took it as "every modified file", but yes,
-u is the right tool to update every known path.