在EclipseJava项目中,将git存储库从旧存储库更改为新存储库

在EclipseJava项目中,将git存储库从旧存储库更改为新存储库,eclipse,git,gitlab,Eclipse,Git,Gitlab,我在Eclipse中有一个项目,它与Gitlab中的一个旧存储库相关联。正在使用的分支称为Test 我在Gitlab中创建了一个新的存储库(其中只有README.md文件)。它只有一个分支:大师 我需要更改Eclipse项目,使其不再引用旧存储库(和旧分支),而是引用新存储库(和主分支) 如何做到这一点 短暂性脑缺血发作 更新 @Rizwan-谢谢你提供的信息。我做了以下工作: cd to the directory with the code #initialize the reposito

我在Eclipse中有一个项目,它与Gitlab中的一个旧存储库相关联。正在使用的分支称为Test

我在Gitlab中创建了一个新的存储库(其中只有README.md文件)。它只有一个分支:大师

我需要更改Eclipse项目,使其不再引用旧存储库(和旧分支),而是引用新存储库(和主分支)

如何做到这一点

短暂性脑缺血发作

更新

@Rizwan-谢谢你提供的信息。我做了以下工作:

cd to the directory with the code

#initialize the repository
git init

#add reference to the repository I needed
git remote add origin "git@myrepo.com: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
cd到带有代码的目录
#初始化存储库
初始化
#添加对所需存储库的引用
git远程添加源”git@myrepo.com:WORK/.git“
#已获取存储库中当前的内容
git拉源主机
#添加的代码(不在存储库中)
git添加-A
#提交代码
git commit-m“使用代码首次提交”
#送上去的
git推送源主机
我用另一条消息作为基础(但我现在找不到)

TIA

这可能会有所帮助

  • 在本地计算机上找到项目。您可以通过运行以下命令来执行此操作:
  • cd/path/to/repo

  • 然后检查并确认所有现有遥控器的列表。要执行此操作,请运行以下命令:
  • git-remote-v

  • 使用git remote set URL命令更改远程服务器的URL:
  • git远程设置url源gitlab@gitlab.mydomain:root/testproject.git

  • 通过第2步检查您的回购协议是否已更改

  • 刷新/清理构建您的Eclipse项目

    我们可以直接在Eclipse本身中执行此操作

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