top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

Creating and Configuring a GIT Repository with Eclipse IDE project

Hello Readers,


Welcome to my blog. Here we are going to learn about How to configure a local eclipse project with Git repository and a perform push, pull activities for a project.

 

GitHub Overview

GitHub is a cloud-based platform where you can store, share, and work together with others to write code.

·        Focused on centralized source code hosting

·        Administered through the web

·        Provides a desktop interface named GitHub Desktop

·        Includes both free and pay-for-use tiers

 

Git Overview

Git is a version control system that intelligently tracks changes in files. Git is particularly useful when you and a group of people are all making changes to the same files at the same time. A commit is just a snapshot of current files when we edit a file, Git will help us determine exactly what was changed, who changed it.

·        Focused on version control, team collaboration and code sharing

·        Primarily a command line tool

·        Provides a desktop interface named Git GUI

·        Open Source licensed

·        Git does not need GitHub, but GitHub needs Git

 

Steps to implement


1.      Create Maven Project in Eclipse IDE

Create a Maven Project in Eclipse IDE in your local system.

 

2.      Create Git Repository

Create Git repository as shown below. The repository can be either public or private based on your requirement.


ree

 

Below screen will be displayed once the repository is created.

Next we need to initialize Git and configure the remote repository. Only then we can push our code to the git repository.

 

ree

 

3.      Initialize Git in the Project Folder

Open the terminal from your eclipse project and execute the command:

git init

 

ree

 

This will initialize Git in your local workspace, and you can see a .git file in your workspace. 


ree

 

4.      Set Your Remote Repository

For remote configuration, execute the below command:

git remote add origin SSHvaluefromYourRepository

 

ree

 

5.      Enable Staging via Team -> Share Project

Now let us enable staging view.

For this right click your project->Team->Share Project->Select your project and Finish.

 

ree

 

Once configured, you can see the branch name (by default master) next to your project in Eclipse.

 

ree

 

To verify which remote repository your workspace is connected to, execute:

git remove –v

 

ree

 

6.      Create a Branch and Push

By default, a master branch will be created locally. If you want to rename it to main, execute:

git branch –M main

 

ree

 

Now create a new branch for the work (example : explore) and switch to it:

git checkout –b explore

 

ree

 

The explore branch is created and switched. Refresh the project if you don’t see it or just click the project name.

ree

 

7.      Commit and Push:

Push can be done in 2 ways. First, through Git staging window and second, via terminal.

 

Option 1: Push through Git Staging Window

Go to Window->Show View->Other…->Git->GitStaging

·        Add the needed files from Unstaged to Staged

·        Enter a commit message

·        Choose Commit or Commit and Push

 

ree

Option 2: Push through Terminal

Open the terminal through the eclipse project and execute the following command lines

 

ree

 

git status     (Used to see staged and unstaged files)

git add .       (Used to move unstaged files to staged files, dot refers to all files)

git commit –m “first commit”     (Give appropriate message)

git push –u origin main (Pushing main branch to git repository. –u means setting upstream for the first commit.)

 

Similarly, push the explore branch:

 git push –u origin explore.

 

For later push, no need to add set upsteam and just use

git push origin explore

 

ree

 

Pushed branches and the commit message will be displayed in Git repository.

 

ree

 

8.      Manage with Pull Request in GitHub GUI

When you push a branch with changes, create a pull request (PR) in GitHub.

·        Click Compare & Pull Request

·        Enter a title and description

·        Click Create Pull Request

 

ree

 

Created pull requests are available under Pull request tab.

 

ree

 

If there are no conflicts, the Merge Pull Request button will be enabled. Once merged, the updates from your branch are merged into the main branch.

 

ree

 

9.      Pull main and merge with branch in Local:

Before starting your work, always pull the latest code. Switch to the main branch and execute:

git pull origin main


ree

Now your local main branch is up to date.

Next update your work branch (explore) with the latest main changes:

git checkout explore

git merge main


If merge conflicts occur, fix them, commit, and then re-run the merge.

 

Conclusion

            It’s always best to work on a separate branch (like explore) instead of directly working on main. Push that branch to GitHub, raise a pull request, and merge changes into main. This ensures conflicts are caught early stage and resolved before merging.

 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page