Farooque
Farooque

Reputation: 3796

Integrate git into an existing project in eclipse

I want to integrate git into an existing project created using eclipse IDE.

Currently, I have the project on location: z:\workspace\myProject

But there are some files and folders that I DON'T want to track with git like:

z:\workspace\myProject\images

z:\workspace\myProject\static_info.txt

z:\workspace\myProject\static_info_class.class

How do I add git to this environment without breaking the project, which is running fine?

Also the git repository has already been created on remote server having url as : https://<username>@<server_location.com>:<port>/parent_dir/myproject.git

So I want to checkin my project in git repository which is already existing using eclipse IDE.

I have installed EGIT in my eclipse IDE.

Note: I don't want to clone the project into new workspace and place my working project into newly created location <somepath>\myproject then commit and push whole project.

Upvotes: 1

Views: 140

Answers (2)

Gauthaman Sahadevan
Gauthaman Sahadevan

Reputation: 943

Do you have Git bash?

If yes, go to the location z:/workspace/

git init

add *.jpeg, *.txt and *.class in your .gitignore file

then add the project related files to your stage

git add .

and then commit your code locally using

git commit -m "Your Custom Commit Messages"

then to push your code to the remote do the below

git remote add origin https://<username>@<server_location.com>:<port>/parent_dir/myproject.git

git push origin master

You can verify your current project in remote using the command

git remote -v

I am sure EGIT can also help you do the above steps. I hope this helps in some way.

Upvotes: 1

Ramzendo
Ramzendo

Reputation: 606

In a existing project in Eclipse you have to right click on the project and the go to Team -> Share Project -> Git.

After that you will get in Eclipse all options provided by Git. There you can also "ignore" files right click on them and going to "Team" option.

I hope it helps.

Upvotes: 0

Related Questions