Hello so I'm working on a Java project for a class, using Intellij. My teacher does not want an SRC folder or anything else that Intellij makes on the Github Repo. Would it be possible to initialize a git repository in the SRC? or would it create problems for Intelj
Asked
Active
Viewed 441 times
0
-
Hint: git does not care about `src` folder. Intellij is the one who uses the `src` folder as default for java projects. – Rafa Sep 14 '17 at 23:25
2 Answers
0
Check this page. You can exclude IntelliJ IDEA project files (.idea
directory and .iml
files from the version control).
Here is the sample .gitignore for IntelliJ IDEA projects that you can adjust for your needs.

CrazyCoder
- 389,263
- 172
- 990
- 904
0
There are several possibilities to approach this problem:
- Create the git-repository in a separate folder. Note though that this approach is a bit tricky to get right! There are actually two options for this:
git --work-tree=<project-location>/src
to use git from a separate directory.git --git-dir=<rep-location>
to use the specified location for the repository. This will require you to use--git-dir
every time.
- Initialize the repository inside the src-folder. This one for sure is ugly, but IntelliJ shouldn't care at all about any non-java files during compilation and if it still complains you could even exclude the directory from being compiled
- Use a
.gitignore
-file to exclude files from VCS. This would leave the src-folder in the repository, but apart from that you can exclude any file you feel like from being versioned. (See the official documentation and @CrazyCoders answer for more details on this) - Do something funny with symlinks. I.e. create the repository somewhere else, place a symlink in the src-folder and use the repository via the symlink.