{"thread":{"id":"18084","subject":"merge, keeping the remote as a new file?","startedAt":"2009-03-02T00:16:10Z","lastAt":"2009-03-02T13:05:42Z","messageCount":7,"participants":["Caleb Cushing","Jeff King","Charles Bailey","Björn Steinbrink","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106660","messageId":"81bfc67a0903011616w32ebdad9ofc096f5d1fd3174a@mail.gmail.com","threadId":"18084","inReplyTo":null,"subject":"merge, keeping the remote as a new file?","fromName":"Caleb Cushing","fromEmail":"xenoterracide@gmail.com","sentAt":"2009-03-02T00:16:10Z","receivedAt":"2009-03-02T00:16:10Z","isPatch":false,"sender":{"key":"xenoterracide@gmail.com","avatar":"https://gravatar.com/avatar/af3f0745dfa0ea9c4ee551d7d0a3cfe7ba8d229754c11678ab2ed23c3fa57065?d=mp&s=160"},"body":" I have an unmerged file... the resolution I'd like to have is\ncheckout the local one for the current file name. take the remote\nversion and give it a new file name. what's the best way to do that?\n\n-- \nCaleb Cushing\n\nhttp://xenoterracide.blogspot.com\n"},{"id":"106665","messageId":"20090302041113.GA3094@coredump.intra.peff.net","threadId":"18084","inReplyTo":"81bfc67a0903011616w32ebdad9ofc096f5d1fd3174a@mail.gmail.com","subject":"Re: merge, keeping the remote as a new file?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-02T04:11:13Z","receivedAt":"2009-03-02T04:11:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Mar 01, 2009 at 07:16:10PM -0500, Caleb Cushing wrote:\n\n>  I have an unmerged file... the resolution I'd like to have is\n> checkout the local one for the current file name. take the remote\n> version and give it a new file name. what's the best way to do that?\n\nI would use:\n\n  $ git show :2:file >file\n  $ git show :3:file >newfile\n  $ git add file newfile\n\nYou can do the first with \"git checkout --ours\", but I don't think there\nis a way with \"checkout\" to say \"checkout this path, but put it in a\ndifferent place\".\n\n-Peff\n"},{"id":"106666","messageId":"20090302063604.GA17245@hashpling.org","threadId":"18084","inReplyTo":"20090302041113.GA3094@coredump.intra.peff.net","subject":"Re: merge, keeping the remote as a new file?","fromName":"Charles Bailey","fromEmail":"charles@hashpling.org","sentAt":"2009-03-02T06:36:04Z","receivedAt":"2009-03-02T06:36:04Z","isPatch":false,"sender":{"key":"charles@hashpling.org","avatar":"https://avatars.githubusercontent.com/u/1668475?v=4"},"body":"On Sun, Mar 01, 2009 at 11:11:13PM -0500, Jeff King wrote:\n> On Sun, Mar 01, 2009 at 07:16:10PM -0500, Caleb Cushing wrote:\n> \n> >  I have an unmerged file... the resolution I'd like to have is\n> > checkout the local one for the current file name. take the remote\n> > version and give it a new file name. what's the best way to do that?\n> \n> I would use:\n> \n>   $ git show :2:file >file\n>   $ git show :3:file >newfile\n>   $ git add file newfile\n> \n> You can do the first with \"git checkout --ours\", but I don't think there\n> is a way with \"checkout\" to say \"checkout this path, but put it in a\n> different place\".\n> \n> -Peff\n\nYou can use git checkout-index --temp --stage=3 and then move it from\nthe auto-generated temporary name into its new place.\n\nThe shell function checkout_staged_file in git-mergetool.sh does this\nprogrammatically, it's not very beautiful as the output of\ncheckout-index --temp requires a bit of expr magic to get the\ntemporary file name out.\n\nUsing a checkout variant instead of a show or a cat-file might be\nimportant if you are doing autocrlf or some other smudging.\n\n-- \nCharles Bailey\nhttp://ccgi.hashpling.plus.com/blog/\n"},{"id":"106667","messageId":"20090302064519.GA5635@coredump.intra.peff.net","threadId":"18084","inReplyTo":"20090302063604.GA17245@hashpling.org","subject":"Re: merge, keeping the remote as a new file?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-02T06:45:19Z","receivedAt":"2009-03-02T06:45:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Mar 02, 2009 at 06:36:04AM +0000, Charles Bailey wrote:\n\n> You can use git checkout-index --temp --stage=3 and then move it from\n> the auto-generated temporary name into its new place.\n\nHmm. I was hoping there was something that would use the name \"--theirs\"\ninstead of the mysterious \"stage level 3\". But it's still nicer than the\n\"git show\" I gave because of:\n\n> Using a checkout variant instead of a show or a cat-file might be\n> important if you are doing autocrlf or some other smudging.\n\nRight. For some reason I was thinking that cat-file did not handle this\nbut \"git show\" did, but I just tested and it clearly doesn't. So yes,\nyou should definitely use checkout-index if you care about conversions.\n\n-Peff\n"},{"id":"106668","messageId":"20090302065949.GD6289@atjola.homenet","threadId":"18084","inReplyTo":"20090302064519.GA5635@coredump.intra.peff.net","subject":"Re: merge, keeping the remote as a new file?","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-03-02T06:59:49Z","receivedAt":"2009-03-02T06:59:49Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.03.02 01:45:19 -0500, Jeff King wrote:\n> On Mon, Mar 02, 2009 at 06:36:04AM +0000, Charles Bailey wrote:\n> \n> > You can use git checkout-index --temp --stage=3 and then move it from\n> > the auto-generated temporary name into its new place.\n> \n> Hmm. I was hoping there was something that would use the name \"--theirs\"\n> instead of the mysterious \"stage level 3\". But it's still nicer than the\n> \"git show\" I gave because of:\n> \n> > Using a checkout variant instead of a show or a cat-file might be\n> > important if you are doing autocrlf or some other smudging.\n> \n> Right. For some reason I was thinking that cat-file did not handle this\n> but \"git show\" did, but I just tested and it clearly doesn't. So yes,\n> you should definitely use checkout-index if you care about conversions.\n\nHm, how about this?\ngit checkout --theirs file\ngit mv file newname\ngit checkout HEAD file # Can't use --ours here due to the mv\n\nShould work with the CRLF stuff, uses no plumbing, no stage numbers,\nthere's no messing with random temp file names and it's still just three\ncommands.\n\nBjörn\n"},{"id":"106669","messageId":"20090302070406.GA12937@coredump.intra.peff.net","threadId":"18084","inReplyTo":"20090302065949.GD6289@atjola.homenet","subject":"Re: merge, keeping the remote as a new file?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-03-02T07:04:06Z","receivedAt":"2009-03-02T07:04:06Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Mar 02, 2009 at 07:59:49AM +0100, Björn Steinbrink wrote:\n\n> Hm, how about this?\n> git checkout --theirs file\n> git mv file newname\n> git checkout HEAD file # Can't use --ours here due to the mv\n\nActually, you can use --ours if you don't \"git mv\":\n\n  git checkout --theirs file\n  mv file newfile\n  git checkout --ours file\n  git add file newfile\n\nOne more command, but I think more obvious about what is going on (and I\nthink both are better than the other suggestions).\n\n-Peff\n"},{"id":"106699","messageId":"76718490903020505j4c4f2df2i379632158f1c80bf@mail.gmail.com","threadId":"18084","inReplyTo":"20090302070406.GA12937@coredump.intra.peff.net","subject":"Re: merge, keeping the remote as a new file?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-02T13:05:42Z","receivedAt":"2009-03-02T13:05:42Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Mon, Mar 2, 2009 at 2:04 AM, Jeff King <peff@peff.net> wrote:\n> On Mon, Mar 02, 2009 at 07:59:49AM +0100, Björn Steinbrink wrote:\n>\n>> Hm, how about this?\n>> git checkout --theirs file\n>> git mv file newname\n>> git checkout HEAD file # Can't use --ours here due to the mv\n>\n> Actually, you can use --ours if you don't \"git mv\":\n>\n>  git checkout --theirs file\n>  mv file newfile\n>  git checkout --ours file\n>  git add file newfile\n>\n> One more command, but I think more obvious about what is going on (and I\n> think both are better than the other suggestions).\n\nThis is a superior answer as well because it avoids plumbing in a\nsituation where plumbing ought not be needed.\n\nj.\n"}]}