Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Netbeans projects in 1 Git repository

Tags:

git

netbeans

We (5 devs) have been working for years on a project consisting of 2 Netbeans projects:

  1. The core, c++ (1 main dev, 3 supporting, I will be added later on). The core can run on it's own through command line.
  2. The gui, java (just me for now). Calls core functionality through a JNI layer or by invoking executables built from the core.

We've reached a point where we would like to start using version control. No one in the team has any (thorough) experience with that, but I (a complete noob) was assigned to investigate and train the team. I've done a lot of research, set my mind to Git and now I'm trying to figure out the best workflow and infrastructure.

I was thinking of 1 repository for the whole project because we are used to having our version number and release notes in sync, in other words, if either the core or the gui is updated, the whole thing will be released as a new version into production. I imagine having only 1 repository greatly simplifies this.

My question right now: Is it possible to have those 2 separate Netbeans projects inside 1 Git repository and still be able to fully utilize Netbeans' Git support, or are 2 repositories the only course of action?

When using Git only through command line, I don't see any trouble, but using Git (also) through Netbeans is a must for our team and as far as I know, 1 Netbeans project equals 1 Git repository ...

like image 483
Q-BiC Avatar asked Oct 13 '13 12:10

Q-BiC


People also ask

Can a Git repo have multiple projects?

Yes. You can put multiple projects in one Git repository but they would need to be on different branches within that repo.

How do I put two projects in one git repository?

Solution 2 Create two independent repositories, and push them to the same remote. Just use different branch names for each repo. Thanks a lot, that should be able to solve my problem. Actually, the two solutions use branchs to hold different projects.


2 Answers

In short - if you want to have multiple projects inside a single Git repository you need to create and use single local git repository for those projects you want to track together.

For example, you want to have two projects mavenproject1 and mavenproject2 inside one solution repository. To achieve this you need:

  1. Create both projects inside one root directory (solution in our case) enter image description hereenter image description here

  2. Choose this directory as the root path while initializing local git repository for the first project enter image description here

  3. After that both projects will show that they have changes to commit

    enter image description here

  4. Sequentially commit both projects to local repository (project->git->commit for each)

  5. Push changes to remote

    enter image description here

  6. Done - you have two projects inside one repo enter image description here

like image 122
Andrey Morozov Avatar answered Sep 18 '22 10:09

Andrey Morozov


Git does not care if it is a netbeans project or just a file or a folder. Git just tracks changes to files.

Note that netbeans is just a facilitator. It does not contribute in any way to your business logic. You can as well use any other text editor to edit/modify code and it will work the same way.

So to answer your question:

Is it possible to have those 2 separate Netbeans projects inside 1 Git repository and still be able to fully utilize Netbeans' Git support, or are 2 repositories the only course of action?

Yes. You can have 2 or any number of netbeans projects in a single git repository. But that would be a horrible choice. You will not be able to track versions of each project independently.

You should create a separate git repository for each one of your projects.

like image 45
Litmus Avatar answered Sep 18 '22 10:09

Litmus