Skip to contentSkip to conversation

Basic Git Questions

DISCUSSION George Spelvin 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw
Quoted 4 lines

1. I generally add the files in my working directory using "git add .". But sometimes you want to add all the files except 1 or 2 file. Is there a shortcut way we can tell git to add all the files but exclude a particular file.

Others have pointed out the general techniques, but a few additional things that may be useful in some situations:

1) .gitignore. If the files are such that you never want git to pay attention to them, you can add them to the .gitignore file.
2) "git add -u". This adds only files that git is already tracking, and ignores truly new files.
3) "git add -i". This lets you pick the files to be added from a list.
4) "git gui". This lets you click on the files to be added. It's my preferred way to do a selective commit.

#1 lore raw
Quoted 2 lines · George Spelvin

1) .gitignore. If the files are such that you never want git to pay attention to them, you can add them to the .gitignore file.

My own preferred pattern is to flip the default: I put a '*' in .gitignore and use "add -f" when I want files tracked.

AK