Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Eclipse java project, change git repository from an old one to a new one

I have a project in Eclipse that is associated with an old repository in Gitlab. The branch being used is called Test.

I created a new repository in Gitlab (and it only has the README.md file in it). It only has one branch: master.

I need to change the Eclipse project so that it no longer refers to the old repository (and old branch) but instead - refers to the new repository (with he master branch).

How can this be done?

TIA

Update

@Rizwan - thanks for the info. I did the following:

cd to the directory with the code

#initialize the repository
git init

#add reference to the repository I needed
git remote add origin "[email protected]:WORK/<my-repository>.git"

#got what was currently in the repository
git pull origin master

#added code (not in the repository) 
git add -A

#commit the code
git commit -m "first commit with code"

#sent it up
git push origin master

There was another message I used as a base (but I cant find it now)

TIA

like image 521
Casey Harrils Avatar asked Jan 03 '23 11:01

Casey Harrils


2 Answers

We can directly perform this operation in Eclipse itself.

Goto - CurrentProject(Right Click) -> Team -> Remote -> Configure push to upstream -> Change(URI)

Procedure in EclipseFinal Window

like image 110
ShubhamDubey Avatar answered Jan 06 '23 15:01

ShubhamDubey


This might help

  1. Locate your project on your local computer. You can do this by running:

cd /path/to/repo

  1. Then check and confirm a list of all of your existing remotes. To do this run this command:

git remote -v

  1. Change the URL of the remote with the git remote set-url command:

git remote set-url origin [email protected]:root/testproject.git

  1. Check back with the step 2 whether your repo has changed

Refresh/Clean Build your Eclipse project

like image 28
Rizwan Avatar answered Jan 06 '23 14:01

Rizwan