如何在 Eclipse 中使用 egit 同步 master 和 origin/master?
我创建了一个本地 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/master
与 master
处于同一级别。
我总是必须执行命令行推送才能使 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按照 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:
master
under both "Source ref" and "Destination ref" to only push yourmaster
branchThe remote-tracking branch
origin/master
is usually updated bygit fetch
(which is part of whatgit 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 updateorigin/master
on a successful push in the same way. If that's the case, you can just do a fetch to updateorigin/master
.Update: It seems that this is a known bug in EGit (not the underlying JGit) - the bug report is here:
对此的更新,我使用的是 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.