What you need to use the file
.gitignore , if you can just select the files that you want to commit a, and do it?
Answer 1, Authority 100%
There are several problems to be solved more efficiently by using the file
Do not bother with the choice of the necessary files for indexing (which
In a large project, it is often a lot of files that are not subject to versioning. His contribution made by the editors and development environments, compilers, debuggers, and other tools and the operating system itself. And yet, you might want to store some intermediate results in the folder
.gitignoreallows you to not pick the files you want, and add it all at once, or at least less elaborate. I agree with the comment Etki , approach” simply select the desired “absolutely does not scale.
Make local configuration, which will not be affected by the pull-th .
Let’s assume, for your project needs configuration. The values in it dependent on the place of performance, the weather and the mood of the developer.
Option 1: do
local.confand make changes if necessary. If you add it all of a sudden and commit an, then you will have conflicts with the pull / push. Or the pull strange configuration will come to you.
Option 2: versioned
local.conf. We use the second, for its formation either manually or automatically using the first. Well, it is convenient and does not interfere with the automation. I have so configurable auto-tests that are run locally on the integration server.
Protect sensitive information from accidental disclosure.
It happens that you accidentally added and commit a keys or passwords from any cloud storage, such as Amazon. And then shove this stuff on GitHub. What you need to do in this situation? Run very fast and change all the keys and passwords, as almost certainly for your account already Mein bitcoins.
If so you need to store sensitive information in the project folder, you need to put it in a sub-folder, ignored by git.
Quickly clean the project from the temporary files .
Suppose that you write a compiled language and the construction of your project is formed by a plurality of intermediate files (object, precompilation, that’s all). Prior to each assembly it is necessary to remove them, so that if something does not link the excess. You can do it manually. It is possible to write a script. And you can just add them to the
.gitignoreand do so:
git clean -fX
Answer 2, Authority 45%
- ignored files will not be listed in the output of
- ignored files will not be added to the index , even if their names are covered by a mask when calling
git add mask
What you need to use a file .gitignore
rather than “necessary” and “possible”: it’s just a convenient
Answer 3, Authority 36%
If you suddenly will be a lot of files that will need to commit an, it will be uncomfortable to enumerate them.
It is therefore easier to specify a list of files that you do not have to keep track of, and everything else considered the project work files and add in a semiautomatic mode.
In the event that the project acquires a large number of CMV logs, files and other automated assembly, easier for them to add a mask to the file
.gitignore and do not worry that they will fall somewhere on your work directory.
In addition, you can create one more or less universal file
.gitignore to your needs (under your “types of” projects) and copy it from the project to the project without the need to create from scratch every time.
p.s. Automation – our everything! (^^,)