3

Suppose two checkouts of a remote repository exist. When doing a commit/push in eGit from the first local repo and then a pull from second local repo, eGit shows a dialogue confirming the commit that is being pulled but in the editor, changed files' contents do not update.

My understanding is that git pull does the merge as well so files in the working directory should be updated. Is this incorrect? What additional step(s) do I need in Eclipse eGit to have the files update content.

marekful
  • 13,318
  • 5
  • 30
  • 52
  • Is there any conflict? Because in that case, the unconflicted files are staged. See http://stackoverflow.com/a/12708545/6309 – VonC Mar 04 '13 at 12:28
  • No conflicts. This is a simplest case of a no-conflict fast forward fetch/merge. – marekful Mar 04 '13 at 12:30
  • And the second repo is on the right branch in EGit? You do see a HEAD as in http://eclipsesource.com/blogs/2011/05/29/life-lesson-be-mindful-of-a-detached-head/ ? You are not in a DETACHED HEAD state? – VonC Mar 04 '13 at 12:34
  • When I do `git pull origin my_remote_branch` on the command line, file content is updated. I want to know how to make Eclipse eGit updating the file contents. Fetch spec is `+refs/heads/*:refs/remotes/origin/*` and push spec is `refs/heads/my_branch:refs/heads/my_branch` at BOTH locals. – marekful Mar 04 '13 at 12:34
  • No, I don't think it's a detached head situation. In history view, for my last commit I see a line starting with `my_branch origin/my_branch FETCH_HEAD HEAD`. – marekful Mar 04 '13 at 12:37
  • Does the history of the file (which should have been updated) shows the new commit? – VonC Mar 04 '13 at 12:55

1 Answers1

1

I'm closing this question as invalid since I figured this was due to a misconfiguration of remote tracking on the 2nd local repo. After fixing it, file contents is updated after a pull as expected. Thanks all of you for your input.

However the fetch/push specs were OK on both sides, remote tracking was incorrect, i.e. in .git/config in the [branch "my_branch"] sections I got the wrong merge spec for the 2nd local repo so that's why pull didn't merge with the local branch I expected.


Some more details about the problem and the fix: like I said, fetch and push specs were OK but as I set up local branches and their tracking on the 2nd machine, I must have made a mistake. In case of the first machine it was correct. In .git/config I saw

[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "1.3.0"]
        remote = origin
        merge = refs/heads/1.3.0
[branch "1.3.0-devel"]
        remote = origin
        merge = refs/heads/1.3.0-devel

However, on the 2nd machine I probably mistyped the commands to create branches and set up tracking so in git branch -t my_branch_1 origin/my_branch_1 repeated for a number of branches all of which I wanted to track the remote branch with the same name, branch names did not match so I ended up with config something like this

[branch "master"]
        remote = origin
        merge = refs/heads/1.3.0-devel
[branch "1.3.0"]
        remote = origin
        merge = refs/heads/master
[branch "1.3.0-devel"]
        remote = origin
        merge = refs/heads/1.3.0

The transaction I referred to in the question happened on the 1.3.0-devel branch: I committed and pushed into origin/1.3.0-devel from the 1st machine, but because on the 2nd 1.3.0-devel did not track origin/1.3.0-devel, pull didn't merge with teh currently checked out 1.3.0-devel local branch.

I fixed this by issuing the command git branch --set-upstream 1.3.0-devel origin/1.3.0-devel and repeating this for all other branches. (Note, this is for git version 1.7.x. For 1.8.x it is different)

Community
  • 1
  • 1
marekful
  • 13,318
  • 5
  • 30
  • 52
  • Can you detail the incorrect config, and compare it to the right config, for others to benefit from it? – VonC Mar 04 '13 at 13:36