3

I have a public repository on Github. In this repository I am sharing single file java applications structured as follows:

Root
  Folder1
    JavaApp1.java
    JavaApp2.java
  Folder2
    JavaApp3.java

In the other hand I am compiling these java applications within IntellijIdea. The problem is, I don't want to share *.iml files etc. in my public repository because I want to keep the repository as simple as possible.

In the other hand I want to store *.iml files etc. in Github for my own need. What can I achieve this requirement with Git?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Gökhan Çoban
  • 600
  • 8
  • 17
  • Use a real build tool like Gradle or Maven, that anybody, whatever the IDE is, can run (outside of the IDE), or import in the IDE to have the IDE-specific files created automatically from the gradle build file or Maven POM. – JB Nizet Aug 19 '16 at 07:47
  • My requirement will remain If I do so. I am also using Gradle with my projects. Let me explain, If I use Gradle, I would like to hide build.gradle file but also I would like to version it. – Gökhan Çoban Aug 19 '16 at 08:02
  • Why would you hide the build.gradle file. It's critical. It's how you build the project (defining dependencies, etc.). And it contains nothing secret. A repository is not simpler if it lacks the single file needed to build it. It's simpler if it contains it, and allows importing the project in any IDE. – JB Nizet Aug 19 '16 at 08:03
  • I will only build the project; thus, I want to version build.gradle for myself. – Gökhan Çoban Aug 19 '16 at 08:05

1 Answers1

2

You would need two repos:

  • one private for Root, including your iml files
  • one public for your Java sources, referenced by the first one as a submodule.

That way, you only clone you first private repo (and get your Root folder), and that will clone the submodule as well (in a "src" subfolder for instance)

cd /my/private/repo
git submodule add  -- /url/public/repo src
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250