Daniel Gafitescu Freelance web developer focused on open source solutions


Manage a GitHub repository in Netbeans 7.1

GitHub create repository

A bit of introduction

As with latest Netbeans version 7.1 it comes with git support integrated inside the IDE, along with SVN and Mercurial.

Since GitHub has become such a popular site for keeping open source repositories as well as private projects ( many companies like Facebook , Twitter are using it to keep their private repositories ).

Since my IDE of choice is  Netbeans I couldn't clone a public repository that I have created on GitHub only using Netbeans ( hope there's a solution and maybe it will be added in a future version it will be added to the IDE but as far as I have tried I coudn't do it).

So in order to create the origin and master branch I had to download and use a separate tool which is easy to install and work with and you have the whole process explained  on GitHub's Set Up page .

If you are a Mac User I advise that you use GitHub for Mac which I have used and works great!

Setup the repository on GitHub

If you don't have an account on github go ahead and create one if you allready have click on the "New Repository" button .

GitHub create repository

GitHub create repository

You are going to be redirected to a form where you need to enter a project title and a description.

After you have created the repository you are redirect to a page where you are instructed how to create the general setting of your name and email , initialize the repository and create the origin and master branches.

Taking the next steps in command line

The steps that are listed in the repository detail page need to be done in command line. As mentioned before everything is explained in detail  on GitHub Setup page.

Since I am on windows I have downloaded the latest Git for Windows installed it , generated a ssh key and add it to my account settings. Once you read that you need to enter the commands listed on the repository detail page on the Git Bash.

 As you can see from the image I setup all in d:\www\codeigniter but you can put it anywhere you want because right after last command I am going to delete it completely so I can clone it again from Netbeans.

Now if you go to the repository detail page all you are going to see it's the readme file.


Netbeans setup

1) Team > Git > Clone

2) Clone the repository , you enter the repository url along with the user/password

3) Select master branch

4) Save to a destination directory. Please note that I have initialized the project from command line in d:\www\codeigniter . Before doing this next step I went and deleted all the files including the hidden ones.

5) Create project from cloned sources

6) Next the project will be created and I will add the new files to it , in my case I have downloaded Codeingiter 2 and add it to the project and I will commit the files using the commit command from the context menu

7) Next you will need to enter the commit message and select the files that you need to add to the commit.

8) After this commit if you go the github repository page you will see that nothing has changes this is because the git system works. Commit will be done one the local created repository

If you open the output view from the Netbeans windows you will see something like this :

9) Next step will be doing the Remote push to Github , and this is done by selecting from the context menu Git > Remote > Push

10) Next you need to select the remote repository from dropdown :

11) Select the Local Branch

12) Update local references which basically copies the master local branch to origin/master branch remote.

13) After this if you go to github repository page you will see all files listed.

And that's it. Again if someone else know how to do this without downloading the command line tool directly for Netbeans let me know.

It would be nice the guys from Netbeans would add this feature in the near future.