Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git command to add/stage modified files in folders only

Tags:

git

dvcs

I've modified several files in a folder and subfolders. I could add the top folder recursively but then i have several subfolders that are untracked, so every time I do the recursive add to stage changes, I have to untrack the subfolders with git rm -r --cached. Is there a better way to just stage the modifications that show up in git status, without tracking already explicitly untracked files?

meta-question: is it really a good idea that git add means two (or more) things? in this context, if the command to track files (git add) were not the same used for stage modifications (git add) then i would not have this problem in the first place

like image 386
lurscher Avatar asked Oct 10 '10 16:10

lurscher


2 Answers

git add -u adds only modifications. Also consider adding files which you don't want to track to .gitignore file.

like image 87
max Avatar answered Sep 23 '22 22:09

max


I think what you're looking for is

git commit -a

This will let you commit changes only.

like image 43
Nigel Avatar answered Sep 23 '22 22:09

Nigel