0

Looked here, but still baffled.

I did a git pull of a branch, followed it by a git fetch.

I still get a message saying my repo is ahead by X commits, and git diff origin/branch, which, to my understanding, compares my local code with a remote branch, shows a delta.

This is after I pulled and fetched, and looking at my code shows that the reported diffs don't actually exist. My code and the upstream code are identical.

I also tried rebasing based on this link, to no avail.

What am I doing wrong?

Thanks!

Community
  • 1
  • 1
MrSilverSnorkel
  • 499
  • 1
  • 5
  • 17
  • see [this](http://stackoverflow.com/questions/14085504/git-whats-the-difference-between-fetching-from-named-remote-and-fetching-from) whether it is helpful. – pktangyue Feb 01 '13 at 18:44
  • 2
    Just FYI: `git pull` is the same as `git fetch` followed by a merge. So doing a `git fetch` directly after a `git pull` is guaranteed to do nothing. – Daniel Hilgarth Feb 01 '13 at 18:47
  • @pktangyue - do you mean that if I want my local repo to actually be synced, I need to include those extra parameters every time? I'm still puzzling out what they mean, though that may be because I'm fairly new to git. At any rate, I can't believe that something as basic as keeping my local repo up to date is so involved, and is beyond a simple command? – MrSilverSnorkel Feb 01 '13 at 19:15
  • @pktangyue - you, that did it, seems to have sorted itself out now. But there must be a simpler way? – MrSilverSnorkel Feb 01 '13 at 19:29
  • Did you ever push? Of course you are ahead if you don't push your changes. – iltempo Feb 01 '13 at 22:37
  • @iltempo - yeah, I pushed, in fact, the delta was exactly the two commits a colleague made since I pushed. Somehow it was claiming that someone else's commits were making my repo ahead of the upstream repo, which is where I got those changes to begin with... – MrSilverSnorkel Feb 01 '13 at 22:57
  • @MrSilverSnorkel did you add any parameters when using `git push` or `git fetch`. – pktangyue Feb 02 '13 at 08:34
  • You say you did `git pull` "of a branch". Which branch? It sounds like your tracking branch is `origin/branch` but you're not pulling that branch? – asm Feb 02 '13 at 17:06
  • Sorry for not responding earlier...initially, when pulling and fetching, I just pulled/fetched the branch, so `git pull origin branch` etc. Later, I tried this with a refspec parameter and the problem went away. Since then, git pull has been working as I would expect it, despite numerous pulls, pushes, and so on. Perhaps my local repository's meta data was somehow not updated, and pulling the refspec helped? – MrSilverSnorkel Feb 05 '13 at 19:11

1 Answers1

0

Do you have commits in your branch you want to keep? Or are you just trying to make your master branch up to date?

Either way:

git stash
git branch master.tmp # or whatever name you want - this saves any changes
git checkout master.tmp
git pull origin master
git branch -D master
git checkout master --force
git stash pop

This will cause you to have two branches: The master (up to date) and your current one (master.tmp)

jchapa
  • 3,876
  • 2
  • 25
  • 38