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.
Pull from remote repository
Because you already commit to remote repository, that’s because of automatically added readme.md 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.
Connect branch with local origin branch where files will be synchronized from remote server.
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.
Select local branch to push.
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.