开发者

How do I synchronize master and origin/master using egit in eclipse?

开发者 https://www.devze.com 2023-04-05 14:18 出处:网络
I created a local git repository, and I push changes from it to a gitosis remote that I created with git init my_git

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 previ开发者_如何学运维ous 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?


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:

  • Push does not update remote tracking branch


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号