{"thread":{"id":"25275","subject":"Qn about git pull and git fetch","startedAt":"2010-09-28T16:59:03Z","lastAt":"2010-09-28T20:01:19Z","messageCount":5,"participants":["suvayu ali","Brian Gernhardt","Eric Raible"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"151933","messageId":"AANLkTi=-UU8X-7h8c4=UENRwNe+G2xGy54YhvWPnnY7y@mail.gmail.com","threadId":"25275","inReplyTo":null,"subject":"Qn about git pull and git fetch","fromName":"suvayu ali","fromEmail":"fatkasuvayu+linux@gmail.com","sentAt":"2010-09-28T16:59:03Z","receivedAt":"2010-09-28T16:59:03Z","isPatch":false,"sender":{"key":"fatkasuvayu+linux@gmail.com","avatar":"https://gravatar.com/avatar/f1adf659f41e5846ddf6ab73bb474a3d9c29ac8ff8fa32adbf5796fc945096d0?d=mp&s=160"},"body":"Hi everyone,\n\nThis is my first post to the list. I am a new (few months now) git\nuser and I use it for source code and notes for my research projects.\nI noticed something during the course of my use. If I have a remote\ntracking repository, and I do a `git pull origin master', the latest\nchanges are merged into my currently checked out branch. But the\nreferences to the remote repo are not. So when I fire up gitk like\nthis, `gitk --all &' I don't see the latest commits for origin/master.\nI have to manually run `git fetch origin' or `git remote update\norigin' to see the updated commits in gitk.\n\nThis is not an inconvenience for me, just a little puzzling since the\nman page says git pull runs `git fetch' followed by `git mege'. Just\nout of curiosity, is there any reason for this choice?\n\n-- \nSuvayu\n\nOpen source is the future. It sets us free.\n"},{"id":"151936","messageId":"9732E43E-124D-4145-A289-2E78F2277ACE@gernhardtsoftware.com","threadId":"25275","inReplyTo":"AANLkTi=-UU8X-7h8c4=UENRwNe+G2xGy54YhvWPnnY7y@mail.gmail.com","subject":"Re: Qn about git pull and git fetch","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-28T17:33:42Z","receivedAt":"2010-09-28T17:33:42Z","isPatch":false,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 28, 2010, at 12:59 PM, suvayu ali wrote:\n\n> If I have a remote tracking repository, and I do a `git pull\n> origin master', the latest changes are merged into my currently\n> checked out branch. But the references to the remote repo are not.\n\n> This is not an inconvenience for me, just a little puzzling since the\n> man page says git pull runs `git fetch' followed by `git mege'. Just\n> out of curiosity, is there any reason for this choice?\n\n`git pull origin master` does the following:\n- `git fetch origin master` will fetch the master branch from remote\n   origin into FETCH_HEAD\n- `git merge` will then merge FETCH_HEAD into HEAD\n\nIt sounds like what you want is to get your branch as a tracking branch.\nIf you see the following in `git remote show origin`:\n\n[...]\n  Local branch configured for 'git pull':\n    master merges with remote master\n[...]\n\nThen all you have to do is `git pull`.  It will update all tracking\nbranches for origin, then merge origin/master into master.  The command\n`git pull origin master` is telling git to override whatever defaults it\nhas and merge the master branch from remote origin into your current HEAD.\n\nYour branches should be set to track automatically but if they didn't for\nsome reason and are using v1.7.0 or newer, you can:\n\n$ git branch --set-upstream master origin/next\nBranch master set up to track remote branch next from origin.\n$ git pull\n\nIf you're using git prior to v1.7.0, you can instead:\n\n$ git config branch.master.remote origin\n$ git config branch.master.merge refs/heads/master\n$ git pull\n\n(Note: You only have to use `git branch --set-upstream` or the `git\nconfig ...` lines once, not before every pull.)\n\n~~ Brian\n"},{"id":"151949","messageId":"AANLkTin1F+y1LZ8VQse_+NZP1pJuS9bnKHb4=23un29k@mail.gmail.com","threadId":"25275","inReplyTo":"9732E43E-124D-4145-A289-2E78F2277ACE@gernhardtsoftware.com","subject":"Re: Qn about git pull and git fetch","fromName":"suvayu ali","fromEmail":"fatkasuvayu+linux@gmail.com","sentAt":"2010-09-28T19:09:10Z","receivedAt":"2010-09-28T19:09:10Z","isPatch":false,"sender":{"key":"fatkasuvayu+linux@gmail.com","avatar":"https://gravatar.com/avatar/f1adf659f41e5846ddf6ab73bb474a3d9c29ac8ff8fa32adbf5796fc945096d0?d=mp&s=160"},"body":"Hi Brian,\n\nOn 28 September 2010 10:33, Brian Gernhardt <brian@gernhardtsoftware.com> wrote:\n>\n> On Sep 28, 2010, at 12:59 PM, suvayu ali wrote:\n>\n>> If I have a remote tracking repository, and I do a `git pull\n>> origin master', the latest changes are merged into my currently\n>> checked out branch. But the references to the remote repo are not.\n>\n>> This is not an inconvenience for me, just a little puzzling since the\n>> man page says git pull runs `git fetch' followed by `git mege'. Just\n>> out of curiosity, is there any reason for this choice?\n>\n> `git pull origin master` does the following:\n> - `git fetch origin master` will fetch the master branch from remote\n>   origin into FETCH_HEAD\n> - `git merge` will then merge FETCH_HEAD into HEAD\n>\n> It sounds like what you want is to get your branch as a tracking branch.\n> If you see the following in `git remote show origin`:\n>\n> [...]\n>  Local branch configured for 'git pull':\n>    master merges with remote master\n> [...]\n>\n> Then all you have to do is `git pull`.  It will update all tracking\n> branches for origin, then merge origin/master into master.  The command\n> `git pull origin master` is telling git to override whatever defaults it\n> has and merge the master branch from remote origin into your current HEAD.\n>\n\nThat explains it! I was overriding the default hence it didn't track\nthe remote branches as expected. Following the steps you mentioned\nabove confirmed that. On doing just `git pull' gave me the behaviour I\nwas expecting in the first place. :)\n\n> Your branches should be set to track automatically but if they didn't for\n> some reason and are using v1.7.0 or newer, you can:\n>\n> $ git branch --set-upstream master origin/next\n> Branch master set up to track remote branch next from origin.\n> $ git pull\n>\n> If you're using git prior to v1.7.0, you can instead:\n>\n> $ git config branch.master.remote origin\n> $ git config branch.master.merge refs/heads/master\n> $ git pull\n>\n> (Note: You only have to use `git branch --set-upstream` or the `git\n> config ...` lines once, not before every pull.)\n>\n\nThanks a lot for pointing me to these. I am using git v1.7.0.4,\nv1.7.2.3 and v1.7.2.2. The above utilities will be very helpful in the\nfuture to configure exactly how I want my repository to behave.\n\n> ~~ Brian\n>\n\n\n\n-- \nSuvayu\n\nOpen source is the future. It sets us free.\n"},{"id":"151951","messageId":"4CA2473B.2040600@nextest.com","threadId":"25275","inReplyTo":"9732E43E-124D-4145-A289-2E78F2277ACE@gernhardtsoftware.com","subject":"Re: Re: Qn about git pull and git fetch","fromName":"Eric Raible","fromEmail":"raible@nextest.com","sentAt":"2010-09-28T19:51:23Z","receivedAt":"2010-09-28T19:51:23Z","isPatch":false,"sender":{"key":"raible@nextest.com","avatar":null},"body":"On 11:59 AM, Brian Gernhardt wrote:\n> \n\n> Your branches should be set to track automatically but if they didn't for\n> some reason and are using v1.7.0 or newer, you can:\n> \n> $ git branch --set-upstream master origin/next\n> Branch master set up to track remote branch next from origin.\n> $ git pull\n> \n> If you're using git prior to v1.7.0, you can instead:\n> \n> $ git config branch.master.remote origin\n> $ git config branch.master.merge refs/heads/master\n> $ git pull\n\nSeems to me that to be equivalent, the first should be:\n\n\tgit branch --set-upstream master origin/master\n\nor the second should be:\n\n\tgit config branch.master.merge refs/heads/next\n\nEh?\n"},{"id":"151952","messageId":"074C8233-BDFE-43AE-AF0A-2D510BF6F5DF@gernhardtsoftware.com","threadId":"25275","inReplyTo":"4CA2473B.2040600@nextest.com","subject":"Re: Qn about git pull and git fetch","fromName":"Brian Gernhardt","fromEmail":"brian@gernhardtsoftware.com","sentAt":"2010-09-28T20:01:19Z","receivedAt":"2010-09-28T20:01:19Z","isPatch":false,"sender":{"key":"brian@gernhardtsoftware.com","avatar":"https://avatars.githubusercontent.com/u/133455?v=4"},"body":"\nOn Sep 28, 2010, at 3:51 PM, Eric Raible wrote:\n\n> On 11:59 AM, Brian Gernhardt wrote:\n>> \n> \n>> Your branches should be set to track automatically but if they didn't for\n>> some reason and are using v1.7.0 or newer, you can:\n>> \n>> $ git branch --set-upstream master origin/next\n>> Branch master set up to track remote branch next from origin.\n>> $ git pull\n>> \n>> If you're using git prior to v1.7.0, you can instead:\n>> \n>> $ git config branch.master.remote origin\n>> $ git config branch.master.merge refs/heads/master\n>> $ git pull\n> \n> Seems to me that to be equivalent, the first should be:\n> \n> \tgit branch --set-upstream master origin/master\n> \n> or the second should be:\n> \n> \tgit config branch.master.merge refs/heads/next\n> \n> Eh?\n\nOops.  I had forgotten to change the first one after some experimenting on the git.git repo.  I had meant\n\n$ git branch --set-upstream master origin/master\n\nFar more repos have a master branch than a next one.\n\n~~ Brian\n"}]}