We have a problem/misunderstanding with our current git setup. We have local master and a local feature/user branches. The branches are connected to different default remote branches. If I checkout the master and want to pull the latest changes, git tells me that I am ahead of the remote master. Looking at the diff of a file that I expected to be pulled from the remote, I see that it is still an old file, not having the latest changes from the remote.
Here is my sample workflow + output:
$ git checkout master
Already on 'master'
Your branch is ahead of 'origin/master' by 8 commits.
I do not want to push, but I want all files updated locally:
$ git pull origin/master
From git://...
* branch master -> FETCH_HEAD
Already up-to-date.
Now let’s look at a file (somefile) that should have been updated:
$ git diff origin/master somefile
# this is not supposed to show anything but it results in a diff output
diff --git a/... b/...
index ...
---
+++
@@ -1,9 +1,8 @@
...
-remoteText that I actually want to have
+localText that I wanted to be updated/replaced
...
Here is the origin config:
$ git remote show origin
* remote origin
Fetch URL: git://...
Push URL: ssh://...
HEAD branch: master
Remote branches:
juve tracked
horst tracked
master tracked
temp tracked
Local branches configured for 'git pull':
master merges with remote master
feature1-juve merges with remote juve
Local ref configured for 'git push':
HEAD forces to master (fast-forwardable)
Does this mean that the somefile is (wrongly) modified by one of the pending commits?
Unfortunately, before doing the described git checkout master some “wild” merging and branch switching has been going on that I could not track anymore (the whole setup is actually not my own, but my colleagues, who often impatiently clicks around in his Eclipse egit). I believe that some “cross merging” has been done that produces old content to appear in the pending commits for the master branch.
Can you tell me what is wrong here? Where is my/our misunderstanding?
PS: The colleague did a reset and is now working again on her code. Therefore, I cannot easily present you the related git log --pretty=oneline merge logs.
In your case,
git pulldoesn’t need any args, so you may be confusing things by passing theorigin/masterarg to it.It shouldn’t need args because git already knows what remote branch your local
masterbranch refers to (this isorigin/master). You can see this in your .git/config file.Also, I would suggest doing
git pull --rebaseinstead of a regular oldgit pull. This will ‘replay’ the 8 new, local commits on top of the latestmasterand force you do deal with any conflicts. You don’t have to deal with any extra conflicts this way (if you had to deal with them, you would have gotten conflicts with a regulargit pulltoo). The gain with this is that you save face and don’t introduce an un-necessary extra merge commit into the history.