eclipse - 在 Eclipse java 项目中,将 git 存储库从旧的更改为新的

标签 eclipse git gitlab

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

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

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

如何才能做到这一点?

TIA

更新

@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

还有一条我用作基础的消息(但我现在找不到了)

TIA

最佳答案

这可能有帮助

  • 在本地计算机上找到您的项目。你可以通过运行:
  • cd /path/to/repo
  • 然后检查并确认所有现有 Remote 的列表。为此,请运行以下命令:
  • git remote -v
  • 使用 git remote set-url 命令更改 Remote 的 URL:
  • git remote set-url origin gitlab@gitlab.mydomain:root/testproject.git
  • 返回第 2 步检查您的存储库是否已更改

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

    关于eclipse - 在 Eclipse java 项目中,将 git 存储库从旧的更改为新的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46266405/

    相关文章:

    java - 从 Spring 上下文中提取启动错误

    eclipse - 类路径和构建路径之间的区别(在 Eclipse 中)

    git - BitBucket 推送功能分支模型

    git - 单独的克隆,或单独的分支

    git - 在 git 中提取一个已重命名的子目录历史记录

    compare - Gitlab 分支/标签从低版本到更新版本的比较

    docker - Docker 上的 GitLab : how to persist user data between deployments?

    java - 找不到以下类: com. codecarpet.fbconnect.FBLoginButton

    java - Android ADT 插件无法在 Eclipse 上打开 XML 文件

    gitlab - gitlab CI中读写文件