Git and GitHub practical tutorial with Eclipse project–Part 1

In this multi-part series, we will go over various aspects of working with Git and GitHub. We will use the projects created in this website as a practical workspace. In this post, we will add the Eclipse project created here to Git and GitHub. Make sure that Git is already installed as described here and an account created in github.com.

Create empty repository in GitHub

Login to account in github.com and click to create New repository

image

Click ‘Create Repository’. In next screen, click on ssh option:

image

Tell Git who you are

Open Git Bash terminal (from windows Start->All Programs) and set some basic configuration.

Create Local Git repository

Initiate a new git repository in project directory.

It gives a message “Initialized empty Git repository in C:/tvi/Software/workspace_mars/standalone-utils/.git/”

Register new repository with Remote Git repository

GitHub is the remote we want to push the code to. URL for the repo can be found on github repository.

Create .gitignore file

We need to tell git to ignore the files that we do not want to commit to git (java class files, package files, IDE files etc.). The .gitignore file resides in project root directory (C:\tvi\Software\workspace_mars\standalone-utils)

Add project files to staging

Initial commit

Verify commit

image

Push to GitHub

It prompts for github account’s username and password.

Verify in GitHub

image

Leave a Reply

Your email address will not be published.