{"thread":{"id":"26330","subject":"Git repo on a machine with zero commits is ahead of remote by 103 commits.. !","startedAt":"2011-01-25T05:48:41Z","lastAt":"2011-01-25T23:09:36Z","messageCount":4,"participants":["Srirang Doddihal","Johannes Sixt","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"159840","messageId":"AANLkTikj06sjTbNd8afk9cY2=_Hy+kT+J1NCjR-fKP5J@mail.gmail.com","threadId":"26330","inReplyTo":null,"subject":"Git repo on a machine with zero commits is ahead of remote by 103 commits.. !","fromName":"Srirang Doddihal","fromEmail":"om.brahmana@gmail.com","sentAt":"2011-01-25T05:48:41Z","receivedAt":"2011-01-25T05:48:41Z","isPatch":false,"sender":{"key":"om.brahmana@gmail.com","avatar":null},"body":"Hi,\n\nI am using a simple git based deployment for my rails app and here is\nmy setup and current status:\n\n1) Git repo initialized on my local development machine with a sample file.\n2) Pushed to remote repo on Github.com\n3) Subsequent pushes and pulls made from local development machine\n4) Repository cloned on the deployed machine\n5) Subsequent pulls made from the deployed machine (but no commits or\npushes are made on this machine)\n\nNow when I run \"git status\" on the deployed machine it says :\n\n# On branch master\n# Your branch is ahead of 'origin/master' by 103 commits.\n\ngit pull origin master -- says it is Already up to date\n\ngit log -- appropriately shows till the latest commit\n\nhowever\n\ngit log orign/master -- shows commits only till Jan 8th.\n\nalso\n\ngit rev-parse origin/master -- give different SHA1 values on my\ndevelopment machine and the deployed machine.\n\nQuestions:\n===========\n1) Why does \"git status\"  say that the local repo on the deployed\nmachine (where no commits are made) is ahead of the remote by 103\ncommits? (This number, 103, increases with every \"git pull origin\nmaster\" and very likely the change is equal to the number of commits\npulled)\n\n2) Why is \"git log orign/master\" stuck at a Jan 8th commit?\n\n* How can I set these right?\n\nEven with these anomalies, \"git pull origin master\" on the deployed\nmachine seems to be working just fine, in terms of the right revisions\nof files being pulled in and all that.\n\nAny help in understanding what caused these anomalies and suggestions\nto fix then would be very helpful.\nKindly let me know if any more information is needed.\n\n-- \nRegards,\nSrirang G Doddihal\nBrahmana.\n\nThe LIGHT shows the way.\nThe WISE see it.\nThe BRAVE walk it.\nThe PERSISTENT endure and complete it.\n\nI want to do it all ALONE.\n"},{"id":"159841","messageId":"4D3E7A22.7090008@viscovery.net","threadId":"26330","inReplyTo":"AANLkTikj06sjTbNd8afk9cY2=_Hy+kT+J1NCjR-fKP5J@mail.gmail.com","subject":"Re: Git repo on a machine with zero commits is ahead of remote by 103 commits.. !","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-01-25T07:22:10Z","receivedAt":"2011-01-25T07:22:10Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 1/25/2011 6:48, schrieb Srirang Doddihal:\n> I am using a simple git based deployment for my rails app and here is\n> my setup and current status:\n> \n> 1) Git repo initialized on my local development machine with a sample file.\n> 2) Pushed to remote repo on Github.com\n> 3) Subsequent pushes and pulls made from local development machine\n> 4) Repository cloned on the deployed machine\n> 5) Subsequent pulls made from the deployed machine (but no commits or\n> pushes are made on this machine)\n> \n> Now when I run \"git status\" on the deployed machine it says :\n> \n> # On branch master\n> # Your branch is ahead of 'origin/master' by 103 commits.\n> \n> git pull origin master -- says it is Already up to date\n\nThis 'git pull' is very explicit. I.e., you specify the remote and the\nbranch; in this case, no remote-tracking branches, like origin/master, are\nupdated.\n\nSince you cloned the repository (I assume without any special options),\nyou already have a configuration such that you can use this shorter command:\n\n   git pull\n\nto merge origin's master into your local master. As a side-effect, it also\nupdates origin/master.\n\n-- Hannes\n"},{"id":"159842","messageId":"AANLkTinC7yvHJj_onRRWBYaZ23Pvs0JB2DJT44Jy-JLG@mail.gmail.com","threadId":"26330","inReplyTo":"AANLkTikj06sjTbNd8afk9cY2=_Hy+kT+J1NCjR-fKP5J@mail.gmail.com","subject":"Re: Git repo on a machine with zero commits is ahead of remote by 103 commits.. !","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-01-25T07:23:05Z","receivedAt":"2011-01-25T07:23:05Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Tue, Jan 25, 2011 at 12:48 AM, Srirang Doddihal\n<om.brahmana@gmail.com> wrote:\n\n> 1) Why does \"git status\"  say that the local repo on the deployed\n> machine (where no commits are made) is ahead of the remote by 103\n> commits? (This number, 103, increases with every \"git pull origin\n> master\" and very likely the change is equal to the number of commits\n> pulled)\n\ngit status is comparing refs/heads/master, aka master, to its\nremote-tracking branch, refs/remotes/origin/master, aka origin/master.\n\nmaster is ahead of origin/master because you've been updating the\nformer but not the later, with your pull invocation.\n\n> 2) Why is \"git log orign/master\" stuck at a Jan 8th commit?\n\nBecause you've been saying \"git pull origin master\", git has been\ndoing the following:\n\n- contacting origin and fetching all commits in its master not in your\nlocal repo\n- locally updating FETCH_HEAD with the results of that fetch\n- performing a merge operation of FETCH_HEAD into your local master\n- because you haven't made any local commits, that is a fast-forward operation\n- updating your work tree\n\nHowever, git is not updating your remote-tracking branch (origin/master).\n\n> * How can I set these right?\n\nJust do a \"git pull\" or \"git pull origin\". By not explicitly giving\npull a branch, it consults two configuration variables in your\n.git/config for the currently checked out branch to figure out what\nyou want it to do, namely:\n\n  branch.master.remote\n  branch.master.merge\n\nAlso in this case, it updates the origin/master remote-tracking branch.\n\n(I think there has been previous discussion about this behavior - it\nseems broken to me that \"git pull <remote> <branch>\" doesn't update\nthe corresponding remote-tracking branch <remote>/<branch> in the case\nwhere \"git pull [<remote>]\" would normally do so according to that\nrepo's .git/config.)\n\nj.\n"},{"id":"159857","messageId":"AANLkTim32q=M1fiEhRf=oxg_U9+Liz8vzdfERJTt0QbQ@mail.gmail.com","threadId":"26330","inReplyTo":"AANLkTinC7yvHJj_onRRWBYaZ23Pvs0JB2DJT44Jy-JLG@mail.gmail.com","subject":"Re: Git repo on a machine with zero commits is ahead of remote by 103 commits.. !","fromName":"Srirang Doddihal","fromEmail":"om.brahmana@gmail.com","sentAt":"2011-01-25T23:09:36Z","receivedAt":"2011-01-25T23:09:36Z","isPatch":false,"sender":{"key":"om.brahmana@gmail.com","avatar":null},"body":"Thank you  Jay and Johannes. A 'git pull' solved the problem and I now\nunderstand git a little better. :)\n\n-- \nRegards,\nSrirang G Doddihal\nBrahmana.\n\nThe LIGHT shows the way.\nThe WISE see it.\nThe BRAVE walk it.\nThe PERSISTENT endure and complete it.\n\nI want to do it all ALONE.\n"}]}