tags:

views:

36

answers:

1

Ok, I'm starting to get the hang of things.

When previewing changes to a repo prior to pulling from it, why doesn't it show the changes I've made in my clone repo if I do the following?

git fetch

git log HEAD..origin

Please see this thread on how my workflow is setup. http://stackoverflow.com/questions/1613812/git-difference-between-tracking-a-branch-versus-cloning

If I run the commands above in a cloned repo it works fine. I can see the changes I made in the "log" file. If I run it on my laptop (the original place where initialize git from), I don't get an update when running the git log command. I can run git pull and it pulls the new changes over just fine.

Is it because I'm not "tracking" the repo?

A: 

Okay, I've had some trouble sorting through what you described of your workflow. In particular, I'm not sure how you got content into your VPS repo... but I'll assume you did it somehow.

Edit: origin in this case is in fact a synonym for origin/HEAD, so the command should still work, though it's often a good idea to explicitly specify the branch. If you get into the habit of using HEAD..origin you may well try to use it on a branch besides master, and then end up effectively doing dev..origin/master which is not at all what you want!

The issue was most likely because the remote had never actually been fetched, which in turn was due to the way the origin remote was added to the repository. In fact, git should give an error in this case:

fatal: ambiguous argument 'HEAD..origin': unknown revision or path not in the work tree
Use '--' to separate paths from revisions

Thanks to Jakub Narębski for setting me straight here!

Jefromi
ah...sorry yes it did show me that error! So, i ran the `git log HEAD..origin/dev and it shows nothing ... as in no output.My workflow is as follows, but now that I think about it, maybe I'm doing it all wrong.From the beginning.I followed this link: http://www.opensourcery.com/blog/alex-kroman/getting-started-gitAny changes I make from my desktop goes back into the repo (i'm tracking the "dev" branch). Back on my laptop I run `git fetch` then a `git log HEAD..origin/dev` and there is no output. If i run `git pull` I get the changes I've made on my workstation.
luckytaxi
I tried it with `git log origin/dev` as well and it doesnt work from the laptop. Is it because I'm not tracking the dev branch on the laptop? I am tracking it on my desktop.
luckytaxi
That will work if and only if the origin/dev remote branch exists within the repository. The best way to keep in sync here is with `git remote update`. This will fetch all remote branches from all remotes.
Jefromi
Don't get too carried away with this "tracking" thing. Remember that it is only an association between a local and remote branch. You are still the one who has to do things like fetch/remote update/pull/push to keep them in sync.
Jefromi
Actually 'origin' means 'origin/HEAD', which usually means 'origin/master' (if you use modern git, with default separate remotes layout).
Jakub Narębski
Really. I thought it might do that but I tried it and got the error. Oddly enough, now I'm not getting it. Must've done something dumb.
Jefromi
Ah, I think I know what it was - the remote had never been fetched. This was likely the case for luckytaxi as well, having manually created the origin remote.
Jefromi
I think that might have been my issue as well, I didn't fetch. I kept going back and forth between commands and then frustration set in and may have forgotten to run git fetch.I understand the whole tracking thing now. I didnt realize that when you clone, it automatically tracks the "master" branch by default. Any additional branches has to be tracked.
luckytaxi