Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

eclipse

egit

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?

like image 224
Mark Fisher Avatar asked Sep 15 '11 10:09

Mark Fisher


People also ask

What does push to origin do in Eclipse?

When using "Push to upstream..." in Eclipse, the new "local" commits are pushed to remote repository and the remote branch ref is updated in the local repository (so master and origin/master reference the same commit).

How do you commit an EGit?

If you want to commit the changes to your repository, right click the project (or the files you want to commit) and select Team => Commit… . This will open a new window, allowing you to select the files you want to commit. Before you can commit the files, you will have to enter a commit message in the upper textbox.


2 Answers

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
like image 84
Mark Longair Avatar answered Nov 02 '22 06:11

Mark Longair


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.

like image 35
Mark Fisher Avatar answered Nov 02 '22 04:11

Mark Fisher