Reputation: 460
I had a discussion with my senior and he asked to commit a file on git (somefile.txt) but not add it to the project (Idea project). I didn't get him at that time and he asked me to leave the topic and drop it.
If I have multiple projects in a folder that is in a git repo, then what does the title of the question mean?
I am not new to git but I think I lack basics of git. Please, clear!
Upvotes: 1
Views: 653
Reputation: 45769
Commit the file means that it should be tracked in source control. If someone clones (or has a clone of) the repo, and the checkout a given version of your code, they should get the version of somefile.txt
that corresponds to that version of the project.
Adding the file in the project (or not) is an IDE thing. In the case of IDEA, it wants to know about source files (.java) and other assets that drive the build; but it probably doesn't care about a .txt file full of documentation for the developer.
Now you probably wouldn't add something to the project without checking it into source control. (I guess if an IDE is crude enough, you might have to do this for generated files; but the expectation would be that generated files are dynamically added to the build process as needed.)
But nonetheless, adding to the project (giving the IDE information for build purposes) is a totally separate thing from committing (giving source control the direction to track changes to the file); and with most IDEs, adding to source control without adding to the project can be a reasonable, and even normal, thing to do.
Though it may seem to muddy the waters, it probably is important to note that this is ok because the file is not a type that IDEA needs to know about. For files that do drive the build process, like .java
files, it avoids a lot of trouble if you make sure that the info in the project files is in sync with the set of committed files. (Or better yet, use build tooling such that the IDE-specific project files aren't needed in source control anyway; but it sounds like that's not the way your team has things set up.)
Upvotes: 2
Reputation: 16394
IDEA, the Intellij editor, shows all files in a project in a pane, usually on the left. That's similar to many other editors.
Those files shown are mostly identical to the files and directories in the file system, but they do not have to. For example, hidden folders sucb as git's .git
folder are often ommited from the view because you rarely/never edit them. Other examples are temporary files or build product.
You can right-click on a file or directory in the tree view to remove it from the project. It will not be deleted, but no longer clutter the view.
Upvotes: 0
Reputation: 1285
Commit means to add it to the repo, but depending on what technologies you are using sometimes there is a project file, like one that visual studio or other IDEs keep. Probably means don't add to the project but add to the repo.
Upvotes: 2