{"thread":{"id":"13451","subject":"git pull/merge master on other branch","startedAt":"2008-05-09T05:26:46Z","lastAt":"2008-05-13T17:24:31Z","messageCount":9,"participants":["SungHyun Nam","Johan Herland","Kevin Ballard","Kelvie Wong","Lars Hjemli","Brandon Casey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"76444","messageId":"g00nb3$dlm$1@ger.gmane.org","threadId":"13451","inReplyTo":null,"subject":"git pull/merge master on other branch","fromName":"SungHyun Nam","fromEmail":"goweol@gmail.com","sentAt":"2008-05-09T05:26:46Z","receivedAt":"2008-05-09T05:26:46Z","isPatch":false,"sender":{"key":"goweol@gmail.com","avatar":null},"body":"Hello,\n\nIf I am on a branch (reguarly rebased), I don't want to switch to\nmaster branch, but merge origin into master.\nIf I switch to master and pull and switch to branch, I have to\nrebuild almost of sources.\n\nHow I can pull origin into master without switching to master\nbranch?\n\nThanks,\nnamsh\n"},{"id":"76445","messageId":"200805090824.12772.johan@herland.net","threadId":"13451","inReplyTo":"g00nb3$dlm$1@ger.gmane.org","subject":"Re: git pull/merge master on other branch","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-05-09T06:24:12Z","receivedAt":"2008-05-09T06:24:12Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Friday 09 May 2008, SungHyun Nam wrote:\n> Hello,\n> \n> If I am on a branch (reguarly rebased), I don't want to switch to\n> master branch, but merge origin into master.\n> If I switch to master and pull and switch to branch, I have to\n> rebuild almost of sources.\n> \n> How I can pull origin into master without switching to master\n> branch?\n\nYou can't; merging requires use of the working tree (to resolve conflicts).\n\nHowever, what you can do is make a local clone of your project (cheap,\nbecause it just hardlinks files from the original repo), and checkout the\nmaster branch in the clone, perform the merge (after having set up the same\norigin and retrieved its contents), and then fetch (or push) the result back\ninto the original repo (remember: \"fetch\" instead of \"pull\", since the\nlatter will initiate a merge with your current branch).\n\n\nHave fun! :)\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"76451","messageId":"g011ve$8ln$1@ger.gmane.org","threadId":"13451","inReplyTo":"200805090824.12772.johan@herland.net","subject":"Re: git pull/merge master on other branch","fromName":"SungHyun Nam","fromEmail":"goweol@gmail.com","sentAt":"2008-05-09T08:28:13Z","receivedAt":"2008-05-09T08:28:13Z","isPatch":false,"sender":{"key":"goweol@gmail.com","avatar":null},"body":"Johan Herland wrote, at 5/9/2008 3:24 PM:\n> On Friday 09 May 2008, SungHyun Nam wrote:\n>> Hello,\n>>\n>> If I am on a branch (reguarly rebased), I don't want to switch to\n>> master branch, but merge origin into master.\n>> If I switch to master and pull and switch to branch, I have to\n>> rebuild almost of sources.\n>>\n>> How I can pull origin into master without switching to master\n>> branch?\n> \n> You can't; merging requires use of the working tree (to resolve conflicts).\n> \n> However, what you can do is make a local clone of your project (cheap,\n> because it just hardlinks files from the original repo), and checkout the\n> master branch in the clone, perform the merge (after having set up the same\n> origin and retrieved its contents), and then fetch (or push) the result back\n> into the original repo (remember: \"fetch\" instead of \"pull\", since the\n> latter will initiate a merge with your current branch).\n\nI tested and it seems work fine.\n\n$ mkdir repo; cd repo; git init; echo 'aaa' > a; git add .; git ci -m \n'aaa'; cd ..\n$ git clone repo t; cd t; git co -b test; cd ..\n$ cd repo; echo 'bbb' >> a; git ci -m 'bbb' a; cd ..\n$ git clone t t2; cd t2; git remote add central ../repo; git pull \ncentral master; git push origin; cd ..\n$ cd t; git log; git log master; git rebase master\n\nDid I do correctly?\n\nThanks,\nnamsh\n"},{"id":"76452","messageId":"200805091106.47447.johan@herland.net","threadId":"13451","inReplyTo":"g011ve$8ln$1@ger.gmane.org","subject":"Re: git pull/merge master on other branch","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-05-09T09:06:47Z","receivedAt":"2008-05-09T09:06:47Z","isPatch":false,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Friday 09 May 2008, SungHyun Nam wrote:\n> Johan Herland wrote, at 5/9/2008 3:24 PM:\n> > On Friday 09 May 2008, SungHyun Nam wrote:\n> >> Hello,\n> >>\n> >> If I am on a branch (reguarly rebased), I don't want to switch to\n> >> master branch, but merge origin into master.\n> >> If I switch to master and pull and switch to branch, I have to\n> >> rebuild almost of sources.\n> >>\n> >> How I can pull origin into master without switching to master\n> >> branch?\n> >\n> > You can't; merging requires use of the working tree (to resolve\n> > conflicts).\n> >\n> > However, what you can do is make a local clone of your project\n> > (cheap, because it just hardlinks files from the original repo),\n> > and checkout the master branch in the clone, perform the merge\n> > (after having set up the same origin and retrieved its contents),\n> > and then fetch (or push) the result back into the original repo\n> > (remember: \"fetch\" instead of \"pull\", since the latter will\n> > initiate a merge with your current branch).\n>\n> I tested and it seems work fine.\n>\n> $ mkdir repo; cd repo; git init; echo 'aaa' > a; git add .; git ci -m\n> 'aaa'; cd ..\n> $ git clone repo t; cd t; git co -b test; cd ..\n> $ cd repo; echo 'bbb' >> a; git ci -m 'bbb' a; cd ..\n> $ git clone t t2; cd t2; git remote add central ../repo; git pull\n> central master; git push origin; cd ..\n> $ cd t; git log; git log master; git rebase master\n>\n> Did I do correctly?\n\nLooks good, AFAICS\n\n\nHave fun! :)\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"76467","messageId":"8C649BDA-41CA-4105-86C5-103B4A8BEEC1@sb.org","threadId":"13451","inReplyTo":"200805090824.12772.johan@herland.net","subject":"Re: git pull/merge master on other branch","fromName":"Kevin Ballard","fromEmail":"kevin@sb.org","sentAt":"2008-05-09T17:16:04Z","receivedAt":"2008-05-09T17:16:04Z","isPatch":false,"sender":{"key":"kevin@sb.org","avatar":"https://avatars.githubusercontent.com/u/714?v=4"},"body":"On May 9, 2008, at 1:24 AM, Johan Herland wrote:\n\n> On Friday 09 May 2008, SungHyun Nam wrote:\n>> Hello,\n>>\n>> If I am on a branch (reguarly rebased), I don't want to switch to\n>> master branch, but merge origin into master.\n>> If I switch to master and pull and switch to branch, I have to\n>> rebuild almost of sources.\n>>\n>> How I can pull origin into master without switching to master\n>> branch?\n>\n> You can't; merging requires use of the working tree (to resolve  \n> conflicts).\n>\n> However, what you can do is make a local clone of your project (cheap,\n> because it just hardlinks files from the original repo), and  \n> checkout the\n> master branch in the clone, perform the merge (after having set up  \n> the same\n> origin and retrieved its contents), and then fetch (or push) the  \n> result back\n> into the original repo (remember: \"fetch\" instead of \"pull\", since the\n> latter will initiate a merge with your current branch).\n\n\nIf you know the pull will just be a fast-foward, then you can do  \nsomething like\n\n   git fetch origin && git update-ref master origin/master\n\n-Kevin Ballard\n\n-- \nKevin Ballard\nhttp://kevin.sb.org\nkevin@sb.org\nhttp://www.tildesoft.com\n"},{"id":"76824","messageId":"4828FB7F.3030907@gmail.com","threadId":"13451","inReplyTo":"8C649BDA-41CA-4105-86C5-103B4A8BEEC1@sb.org","subject":"Re: git pull/merge master on other branch","fromName":"SungHyun Nam","fromEmail":"goweol@gmail.com","sentAt":"2008-05-13T02:22:55Z","receivedAt":"2008-05-13T02:22:55Z","isPatch":false,"sender":{"key":"goweol@gmail.com","avatar":null},"body":"Kevin Ballard wrote, at 5/10/2008 2:16 AM:\n > On May 9, 2008, at 1:24 AM, Johan Herland wrote:\n >\n >> On Friday 09 May 2008, SungHyun Nam wrote:\n >>> Hello,\n >>>\n >>> If I am on a branch (reguarly rebased), I don't want to switch to\n >>> master branch, but merge origin into master.\n >>> If I switch to master and pull and switch to branch, I have to\n >>> rebuild almost of sources.\n >>>\n >>> How I can pull origin into master without switching to master\n >>> branch?\n >>\n >> You can't; merging requires use of the working tree (to resolve\n >> conflicts).\n >>\n >> However, what you can do is make a local clone of your project (cheap,\n >> because it just hardlinks files from the original repo), and \ncheckout the\n >> master branch in the clone, perform the merge (after having set up the\n >> same\n >> origin and retrieved its contents), and then fetch (or push) the\n >> result back\n >> into the original repo (remember: \"fetch\" instead of \"pull\", since the\n >> latter will initiate a merge with your current branch).\n >\n >\n > If you know the pull will just be a fast-foward, then you can do\n > something like\n >\n >   git fetch origin && git update-ref master origin/master\n\nIt seems it worked, but I see a warning message \"refname 'master'\nis ambiguous.\" Can I fix this warning message?\n\n[test] ~/tmp/t[52]$ git fetch origin\nremote: Counting objects: 5, done.\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking objects: 100% (3/3), done.\n From /d/user/namsh/tmp/repo/\n    6e13bb5..8d1c620  master     -> origin/master\n[test] ~/tmp/t[53]$ git update-ref master origin/master\n[test] ~/tmp/t[69]$ git log master\nwarning: refname 'master' is ambiguous.\ncommit a358783b78facffb9a8f69d2189aa716495d95ba\n..\n\n[test] ~/tmp/t[54]$ git rebase master\nwarning: refname 'master' is ambiguous.\nwarning: refname 'master' is ambiguous.\nFirst, rewinding head to replay your work on top of it...\nFast-forwarded test to master.\n\nregards,\nnamsh\n"},{"id":"76826","messageId":"94ccbe710805122012t5ef9f8bev502e1933f2f8a8da@mail.gmail.com","threadId":"13451","inReplyTo":"g00nb3$dlm$1@ger.gmane.org","subject":"Re: git pull/merge master on other branch","fromName":"Kelvie Wong","fromEmail":"kelvie@ieee.org","sentAt":"2008-05-13T03:12:14Z","receivedAt":"2008-05-13T03:12:14Z","isPatch":false,"sender":{"key":"kelvie@ieee.org","avatar":null},"body":"On 5/8/08, SungHyun Nam <goweol@gmail.com> wrote:\n\n>  How I can pull origin into master without switching to master\n>  branch?\n>\n>  Thanks,\n>  namsh\n>\n\nTo do this, one would use the \"push\" subcommand, with \".\" as the repository.\n\ngit push . origin/master:master\n\nI could have sworn I answered someone the exact same thing a while ago...\n-- \nKelvie Wong\n"},{"id":"76874","messageId":"8c5c35580805130908h4ee12952sc6581d07391ba73e@mail.gmail.com","threadId":"13451","inReplyTo":"4828FB7F.3030907@gmail.com","subject":"Re: git pull/merge master on other branch","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2008-05-13T16:08:42Z","receivedAt":"2008-05-13T16:08:42Z","isPatch":false,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On Tue, May 13, 2008 at 4:22 AM, SungHyun Nam <goweol@gmail.com> wrote:\n> Kevin Ballard wrote, at 5/10/2008 2:16 AM:\n>\n>  > If you know the pull will just be a fast-foward, then you can do\n>  > something like\n>  >\n>  >   git fetch origin && git update-ref master origin/master\n\nI belive that should be `update-ref refs/heads/master origin/master`,\notherwise you'll get this error:\n\n>  It seems it worked, but I see a warning message \"refname 'master'\n>  is ambiguous.\" Can I fix this warning message?\n\nTry `rm .git/master`.\n\n--\nlarsh\n"},{"id":"76877","messageId":"4829CECF.1090900@nrlssc.navy.mil","threadId":"13451","inReplyTo":"8C649BDA-41CA-4105-86C5-103B4A8BEEC1@sb.org","subject":"Re: git pull/merge master on other branch","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-05-13T17:24:31Z","receivedAt":"2008-05-13T17:24:31Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Kevin Ballard wrote:\n> On May 9, 2008, at 1:24 AM, Johan Herland wrote:\n> \n>> On Friday 09 May 2008, SungHyun Nam wrote:\n>>> Hello,\n>>>\n>>> If I am on a branch (reguarly rebased), I don't want to switch to\n>>> master branch, but merge origin into master.\n>>> If I switch to master and pull and switch to branch, I have to\n>>> rebuild almost of sources.\n>>>\n>>> How I can pull origin into master without switching to master\n>>> branch?\n>>\n>> You can't; merging requires use of the working tree (to resolve\n>> conflicts).\n>>\n>> However, what you can do is make a local clone of your project (cheap,\n>> because it just hardlinks files from the original repo), and checkout the\n>> master branch in the clone, perform the merge (after having set up the\n>> same\n>> origin and retrieved its contents), and then fetch (or push) the\n>> result back\n>> into the original repo (remember: \"fetch\" instead of \"pull\", since the\n>> latter will initiate a merge with your current branch).\n> \n> \n> If you know the pull will just be a fast-foward, then you can do\n> something like\n> \n>   git fetch origin && git update-ref master origin/master\n\nI recommend against using update-ref...\n\nand instead suggest using fetch to do all of the work.\nSome variation of:\n\n    git fetch origin master:master\n\nThis will only fast-forward the master branch based on the remote origin's\nmaster branch. update-ref will blindly overwrite the master ref, if you make\na mistake and its not a fast-forward, you just lost some commits.\n\nThe above doesn't update your remotes though, maybe the following would be\ncorrect, but I haven't tried it.\n\n   git fetch origin && git fetch . remotes/origin/master:master\n\n\n\nAlso, I'm surprised no one mentioned the git-new-workdir script in the\ncontrib directory. It allows you to have multiple work directories\nwhich share and update a single repository.\n\nYou could\n\n    git-new-workdir <path_to_repo> <path_to_newworkdir> master\n    cd <path_to_newworkdir>\n    git pull\n\n-brandon\n"}]}