如何在 Eclipse 中使用 egit 同步 master 和 origin/master?

发布于 2024-12-05 00:52:21 字数 1077 浏览 2 评论 0原文

我创建了一个本地 git 存储库,然后将更改从它推送到我使用现在创建的 gitosis 远程

git init my_git
git remote add origin git@server:my_git
... various adds and commits
git push origin master:refs/heads/master

,我在 eclipse 中本地编辑和提交更改,当我提交时,我看到(使用 qgit)它移动了我的 master 分支到该版本。

但是,它还向我显示 origin/master 是以前的版本。

命令行上的 git status 向我显示一切都是最新的:

$ git status
# On branch master
nothing to commit (working directory clean)

我可以看到版本的差异

git diff origin/master

如果我在命令行上执行 git push ,那么 qgit 会向我显示origin/master 分支现在与我的 master 位于同一位置。

我不知道如何在 Eclipse 中配置“远程/推送”或“远程/配置推送到上游”对话框,以执行与命令行 git Push 相同的操作来移动 origin/mastermaster 处于同一级别。

我总是必须执行命令行推送才能使 origin/master 到达与 master 相同的位置。

Q1.谁能告诉我如何在 eclipse 中做到这一点?

Q2。命令行版本的 git push 能做什么而 eclipse 版本不能做什么?

Q3。我的假设 master 是我的本地 HEAD 指针,而 origin/master 是远程服务器对当前 HEAD 的视图是否正确?

I created a local git repository, and I push changes from it to a gitosis remote that I created with

git init my_git
git remote add origin git@server:my_git
... various adds and commits
git push origin master:refs/heads/master

Now, I edit and commit changes locally in eclipse, and when I commit, I see (using qgit) that it moves my master branch to that version.

However, it also shows me that origin/master is at the previous version.

git status on command line shows me everything is up to date:

$ git status
# On branch master
nothing to commit (working directory clean)

I can see the differences in versions with

git diff origin/master

If i do git push on my command line, then qgit shows me the origin/master branch is now at same place as my master.

I can't work out how to configure the "remote / push" or "remote / configure push to upstream" dialog in eclipse to do the same thing as a command line git push to move the origin/master to the same level as the master.

I always have to do the command line push to make the origin/master come up to the same place as master.

Q1. Can anyone tell me how to do this in eclipse?

Q2. What is the command line version of git push doing that the eclipse version doesn't do?

Q3. Are my assumptions that master is my local HEAD pointer and origin/master is the remote server's view of the current HEAD correct?

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

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

发布评论

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

评论(2

趴在窗边数星星i 2024-12-12 00:52:21

按照 egit 文档 的相关部分,您可以:

  • 单击“添加所有分支规范” ”按钮,将所有本地分支推送到远程存储库中同名的分支,或者
  • (更安全的选项)只需在“源引用”和“目标引用”下选择 master 即可只推动你的master 分支

远程跟踪分支 origin/master 通常由 git fetch 更新(这是 git pull 的一部分) code> 确实如此),但使用命令行 git,远程跟踪分支也会在成功推送到正在跟踪的远程存储库中的分支时更新。 Egit 可能基于 git 的纯 Java 实现之一 JGit,而不是命令行工具,不会以相同的方式在成功推送后更新 origin/master。如果是这种情况,您只需执行提取即可更新origin/master


更新:这似乎是 EGit(不是底层 JGit)中的一个已知错误 - 错误报告位于:

Going by the relevant part of egit's documentation you can either:

  • click the "Add all branches spec" button, to push all of your local branches to ones with the same name in the remote repository, or
  • (the much safer option) just select master under both "Source ref" and "Destination ref" to only push your master branch

The remote-tracking branch origin/master is usually updated by git fetch (which is part of what git pull does), but with command line git, the remote-tracking branch is also updated on a successful push to the branch in the remote repository that's being tracked. It's possible that Egit, being based one of the pure Java implementations of git, JGit, rather than the command-line tools, doesn't update origin/master on a successful push in the same way. If that's the case, you can just do a fetch to update origin/master.


Update: It seems that this is a known bug in EGit (not the underlying JGit) - the bug report is here:

再见回来 2024-12-12 00:52:21

对此的更新,我使用的是 eclipse Helios,并且我已经升级到 Indigo,并使用最新版本的 egit,并且修复似乎处于活动状态,因为我不再需要在推送后拉取。

An update to this, I was using eclipse Helios, and I've upgraded to Indigo, with the latest version of egit, and the fix appears to be active, as I'm no longer having to pull after a push.

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