Reputation: 305
I'm learning to use git to manage a python project.
So far I have been adding files explicitly with "git add", but it seems to be the way in general to include all files with "git add ." except some files mentioned in .gitignore
At the very least, "git status" will imply to me that there are a bunch of files that I should probably say something about.
I'm thinking about just putting:
*
**
in .gitignore, and then continuing as I have been to explicitly include files. This seems to be against the grain of the way Git is intended to be used though.
My question is: is it a bad idea to work in this way and if so why?
Many thanks
Upvotes: 1
Views: 73
Reputation: 1323953
but it seems to be the way in general to include all files with "
git add .
" except some files mentioned in.gitignore
What I generally do when typing git add .
is to follow with a git status
.
If I see way too many files added (because my .gitignore
was not precise enough), I reset, change the .gitignore
, add again, and control again with git status.
git reset
# edit .gitgignore
git add .
git status
Once the status is satisfactory, I commit.
Upvotes: 1
Reputation: 1864
My question is: is it a bad idea to work in this way and if so why?
Yes, it is a bad idea. The purpose of .gitignore
is to specify files you're going to completely exclude from version control.
If your issue is that you don't like typing the names of all files individually, then there are a few options:
If you have many files in the same directory, then you can simply type git add your-directory/
, and all modified files in that directory will be staged.
If there are only a few files you want to exclude (until a later commit), then you can use the tip in #1 or just run git add .
, then manually exclude each file you don't want committed using git reset HEAD file-to-exclude
, which will un-stage the file.
In general, though, you don't want to leave a lot of files modified but unstaged at the same time. This will lead to headaches, and will make it difficult to leverage the power of version control. Try to commit small, logically-related updates one at a time, then move on to another portion of your project.
Upvotes: 1