如何使用 Eclipse EGit 从我的服务器 git 存储库下载/克隆新分支到我的 PC 中已创建的本地 git 存储库

发布于 2024-12-03 07:47:52 字数 709 浏览 3 评论 0原文

这让我发疯。

我在我的托管公司托管的 Linux 服务器中创建了一个 git 存储库。

我使用 Eclipse EGit 将其克隆到本地副本。

然后我在服务器的原始 git 存储库中创建了一个分支。

如何使用 Eclipse EGit 将分支复制到本地副本?

当我在 EGit 中打开 Git 存储库时,我看到:

- Local
-- master

- Remote Tracking
-- origin/development
-- origin/master

How can I get the origin/development in my local using EGit?

我知道我可以创建一个新的克隆,但我不想这样做,因为我相信必须有一种方法只能获取新的分支。

第二个问题 - EGit 中的 pull 命令在哪里?我能够找到 fetch 命令,但当我运行它时,它说没有任何内容可获取。 RefSpec 是:

+refs/heads/*:refs/remotes/origin/*

第三个问题 - 有没有办法在我的 Windows 系统中从 Eclipse 内的命令行处理 git 命令?我想过尝试从命令行进行拉取,但我在本地系统中找不到它。

谢谢。

This is driving me crazy.

I created a git repository in a Linux server hosted by my hosting company.

I cloned it to a local copy using Eclipse EGit.

I then created a branch in the original git repository in the server.

How do I copy the branch to my local copy using Eclipse EGit?

When I open Git Repositories inside EGit I see:

- Local
-- master

- Remote Tracking
-- origin/development
-- origin/master

How can I get the origin/development in my local using EGit?

I know I could create a new clone, but I don't want to do that as I believe there must be a way to get only the new branch.

Second question - where is the pull command inside EGit? I was able to find the fetch command, but when I run it it says that there is nothing to fetch. The RefSpec is:

+refs/heads/*:refs/remotes/origin/*

Third question - is there a way to process git commands from a command line inside Eclipse in my Windows system? I thought about trying to do a pull from a command line, but I can't find it in my local system.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夜未央樱花落 2024-12-10 07:47:52

我还搜索了大约几个小时,以了解如何在 Eclipse EGit 中获取远程分支...

解决方案在 此错误报告。如果你知道怎么做的话,这真的很容易 - 不需要使用 git 的命令行版本,尽管它在 99% 的情况下都可以工作 - 可能会有风险,因为我已经遇到了它干扰 Eclipse 的问题和 Egit。

只需按照以下步骤操作:

  1. 首先确保您已打开 EGit 存储库视图。如果您还没有打开它,请转到“Window → Show View → Other...”,然后选择“Git → Git Repositories”。
  2. 存储库视图中选择“分支→远程跟踪”。您应该已经在那里看到您的远程分支(例如:origin/new_feature)。
  3. 右键单击您希望与本地分支一起使用的远程分支。选择“Create Branch...”
  4. 默认值应该就可以了。 通常您不应在此处更改任何内容。请注意,如果您不知道自己是什么,则不应将“拉动策略”更改为“合并”以外的其他内容正在做。否则,拉动上游更改可能会导致数据丢失。
  5. 单击确定“完成”即可完成:)

I've also been searching around some hours to find out how to get a remote branch in Eclipse EGit...

The solution is stated in this Bugreport. And it is really easy if you know how to do it - no need for using the command line version of git, which - even though it works in 99% of all cases - can be risky as I already had problems that it interfered with Eclipse and EGit.

Just follow these steps:

  1. First make sure you have opened the EGit Repository view. If you haven't opened it already, go to "Window → Show View → Other..." and from there select "Git → Git Repositories".
  2. In the Repository view choose "Branches → Remote Tracking". You should see your remote branches there already (example: origin/new_feature).
  3. Right click on the remote branch you wish to have with your local branches. Choose "Create Branch..."
  4. The default values should be OK. Normally you should not change anything here. Please note that you should not change the "Pull strategy" to something else than "Merge" if you don't know what you are doing. Otherwise pulling upstream changes might result in a loss of data.
  5. Click on OK "Finish" and you are done :)
梅窗月明清似水 2024-12-10 07:47:52

您的获取是最新的,因为您已经将所有内容复制到本地存储库。拉取会将 origin/development 合并到 master 中,这不是您想要的。您想要创建一个以 origin/development 作为起点的新分支。我不知道如何使用 egit 执行此操作,但在命令行上,您可以:

git checkout -b development origin/development

Your fetch is up to date because you already have everything copied to your local repository. A pull will merge origin/development into master, which isn't what you want. You want to create a new branch with origin/development as the starting point. I don't know how to do it with egit, but on the command line, you do:

git checkout -b development origin/development
深海里的那抹蓝 2024-12-10 07:47:52

我也遇到了同样的问题,这是我解决它的方法:

  1. 打开 Git 透视图

  2. 首先,您必须在存储库中

    下拥有要签出的分支em>远程跟踪。我的问题是我在这里看不到远程分支,所以为了解决这个问题 - 在存储库上执行Pull,并且此命令应该为您提供远程跟踪下的所有分支

  3. 右键单击​​(远程)分支,签出,签出为新的本地分支

I have been facing the same problem, and here is how I solved it:

  1. Open Git Perspective

  2. First you must have the branch that you want to check out, in your repository under Remote Tracking. My problem was that I couldn't see the remote branch here, so in order to solve this - execute a Pull on the repository, and this command should get you all the branches under Remote Tracking

  3. right click the (remote) Branch, Check Out, Check out as new local branch
柠檬 2024-12-10 07:47:52

要获取 sts 中的其他分支,如果 pull 不起作用,请尝试此操作
团队>>远程>>配置从上游流获取>高级>
在源参考中检查您想要的分支:>然后添加规格

To get other branches in sts , if pull didn't work then try this
Team >> Remote>> Cofigure fetch from upstream stream>Advanced>
Check branch you want in source ref: > then add spec

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文