Adding a new Spring Maven Project from Eclipse to Git Repo (Bitbucket)

In the last tutorial we learned about how can we create a new Spring Maven Project in Eclipse / STS ( http://wp.me/p58s9B-3 ) . In this tutorial we will learn how can we add our existing project to a Git repository.

Converting a project into a Git helps you maintain’s version of the changes, also extremely useful when there is a team working on the project.

Steps.

1. To add your project into a git repository , first you have to convert your local repository into a Git repository. Open your command line and navigate to the root folder of your project. and type command git init ( you need to have git installed on your system for this command to work)

2. Now you have converted your project into a git project and there is a git repository in your local machine which is currently empty. We’ll commit all the initial files to that repository by running following commands

git add .  ( Add all files)

git commit -m “commit message”

3. We need to have a remote repository where we will push all our local repo commits , so that other users can setup the project on their machine from their machine. I have chose bitbucket.org to store my git repo. Login to bitbucket and Create a new blank git repo.

4. So we are now ready with local git repo with all our project file and a remote  empty git repo. We need to tell our local git repo where the remote repository is and after that we will push all the files to the remote repo. By issuing following commands

git remote add origin https://your.remote.git.url.git

git push -u origin -all

That is all. Your project in Eclipse will now the branch of remote your project will refer to.

tgugnani: Web Stuff Enthusiast.