Connect to Github via Netbeans

Create remote git repository

You need to create new github repository before you can connect local repository to it. Of course you need to have an account on github, but it’s not an issue, it’s free.


On the remote repository find https address of your project and save it for later.


Create local git repository

After creating new project in Netbeans you need to initialize local git repository.

Define exceptions - .gitignore file

But before you do that, create “.gitignore” file where you define all exceptions. In the source control we usually save only code files and configurations, but not binary files, IDE specific files etc.  The file must be in the project root folder.

build.xml /nbproject/ /build/ /web/bower_components/ /web/node_modules/

You can always delete exceptions from “gitignore” file and add files to repository later.


At project node, with the right click, select “Versioning” and “Initialize Git repository".  Initialization procedure add all files in the project, except ignored ones,  to the local repository. Adding a file only mark file for version control. File is not in version control until is committed to.


Commit to local repository

Your files need to be committed to local repository. With right click on project node, select “Git” and “Commit”.  This will create local branch in local repository which will you connect to github.

/images/2016-11-26-23_49_55-Planitia-no-branch-300x279.pngIn the repository browser (/Team/Repository/Repository Browser) you see current state of local git:


Pull from remote repository

Because you already commit to remote repository, that’s because of automatically added and licence files, you must pull those files first and MERGE them to the local repository.  Then you will be able to push all local differences back to remote repository.

/images/2016-11-27-00_27_14-Jump-List-for-Mozilla-Firefox-300x201.pngEnter project URL (https://….), username and password.


Connect branch with local origin branch where files will be synchronized from remote server.

/images/2016-11-27-00_28_25-Pull-from-Remote-Repository-300x164.png And finish. You will merge new files ( and licence) from remote to local git.

Push to remote repository

After you pull new files down or if you didn’t have any to pull, you continue with push.

Select right click on project node and execute Git/Remote/Push.

/images/2016-11-26-23_56_45-Jump-List-for-Mozilla-Firefox-300x197.pngConfigure  URL of your project (https://….), username and password.


Select local branch to push.


And select local origin branch where remote repository is replicated. /images/2016-11-27-00_42_08-Push-to-Remote-Repository-300x172.pngClick Finish and your files will be sent to remote github repository.

Verify remote git repository

If everything went right, you will see all your project files and folders on the github and two new files inside your local project.

/images/2016-11-27-01_11_41-bisaga_Planitia_-This-is-another-test-project-to-see-how-new-stuff-working-toget-300x163.pngThat’s it ! You are connected to new github repository.