* merge, keeping the remote as a new file?
@ 2009-03-02 0:16 Caleb Cushing
2009-03-02 4:11 ` Jeff King
0 siblings, 1 reply; 7+ messages in thread
From: Caleb Cushing @ 2009-03-02 0:16 UTC (permalink / raw)
To: git
I have an unmerged file... the resolution I'd like to have is
checkout the local one for the current file name. take the remote
version and give it a new file name. what's the best way to do that?
--
Caleb Cushing
http://xenoterracide.blogspot.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: merge, keeping the remote as a new file?
2009-03-02 0:16 merge, keeping the remote as a new file? Caleb Cushing
@ 2009-03-02 4:11 ` Jeff King
2009-03-02 6:36 ` Charles Bailey
0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2009-03-02 4:11 UTC (permalink / raw)
To: Caleb Cushing; +Cc: git
On Sun, Mar 01, 2009 at 07:16:10PM -0500, Caleb Cushing wrote:
> I have an unmerged file... the resolution I'd like to have is
> checkout the local one for the current file name. take the remote
> version and give it a new file name. what's the best way to do that?
I would use:
$ git show :2:file >file
$ git show :3:file >newfile
$ git add file newfile
You can do the first with "git checkout --ours", but I don't think there
is a way with "checkout" to say "checkout this path, but put it in a
different place".
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: merge, keeping the remote as a new file?
2009-03-02 4:11 ` Jeff King
@ 2009-03-02 6:36 ` Charles Bailey
2009-03-02 6:45 ` Jeff King
0 siblings, 1 reply; 7+ messages in thread
From: Charles Bailey @ 2009-03-02 6:36 UTC (permalink / raw)
To: Jeff King; +Cc: Caleb Cushing, git
On Sun, Mar 01, 2009 at 11:11:13PM -0500, Jeff King wrote:
> On Sun, Mar 01, 2009 at 07:16:10PM -0500, Caleb Cushing wrote:
>
> > I have an unmerged file... the resolution I'd like to have is
> > checkout the local one for the current file name. take the remote
> > version and give it a new file name. what's the best way to do that?
>
> I would use:
>
> $ git show :2:file >file
> $ git show :3:file >newfile
> $ git add file newfile
>
> You can do the first with "git checkout --ours", but I don't think there
> is a way with "checkout" to say "checkout this path, but put it in a
> different place".
>
> -Peff
You can use git checkout-index --temp --stage=3 and then move it from
the auto-generated temporary name into its new place.
The shell function checkout_staged_file in git-mergetool.sh does this
programmatically, it's not very beautiful as the output of
checkout-index --temp requires a bit of expr magic to get the
temporary file name out.
Using a checkout variant instead of a show or a cat-file might be
important if you are doing autocrlf or some other smudging.
--
Charles Bailey
http://ccgi.hashpling.plus.com/blog/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: merge, keeping the remote as a new file?
2009-03-02 6:36 ` Charles Bailey
@ 2009-03-02 6:45 ` Jeff King
2009-03-02 6:59 ` Björn Steinbrink
0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2009-03-02 6:45 UTC (permalink / raw)
To: Charles Bailey; +Cc: Caleb Cushing, git
On Mon, Mar 02, 2009 at 06:36:04AM +0000, Charles Bailey wrote:
> You can use git checkout-index --temp --stage=3 and then move it from
> the auto-generated temporary name into its new place.
Hmm. I was hoping there was something that would use the name "--theirs"
instead of the mysterious "stage level 3". But it's still nicer than the
"git show" I gave because of:
> Using a checkout variant instead of a show or a cat-file might be
> important if you are doing autocrlf or some other smudging.
Right. For some reason I was thinking that cat-file did not handle this
but "git show" did, but I just tested and it clearly doesn't. So yes,
you should definitely use checkout-index if you care about conversions.
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: merge, keeping the remote as a new file?
2009-03-02 6:45 ` Jeff King
@ 2009-03-02 6:59 ` Björn Steinbrink
2009-03-02 7:04 ` Jeff King
0 siblings, 1 reply; 7+ messages in thread
From: Björn Steinbrink @ 2009-03-02 6:59 UTC (permalink / raw)
To: Jeff King; +Cc: Charles Bailey, Caleb Cushing, git
On 2009.03.02 01:45:19 -0500, Jeff King wrote:
> On Mon, Mar 02, 2009 at 06:36:04AM +0000, Charles Bailey wrote:
>
> > You can use git checkout-index --temp --stage=3 and then move it from
> > the auto-generated temporary name into its new place.
>
> Hmm. I was hoping there was something that would use the name "--theirs"
> instead of the mysterious "stage level 3". But it's still nicer than the
> "git show" I gave because of:
>
> > Using a checkout variant instead of a show or a cat-file might be
> > important if you are doing autocrlf or some other smudging.
>
> Right. For some reason I was thinking that cat-file did not handle this
> but "git show" did, but I just tested and it clearly doesn't. So yes,
> you should definitely use checkout-index if you care about conversions.
Hm, how about this?
git checkout --theirs file
git mv file newname
git checkout HEAD file # Can't use --ours here due to the mv
Should work with the CRLF stuff, uses no plumbing, no stage numbers,
there's no messing with random temp file names and it's still just three
commands.
Björn
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: merge, keeping the remote as a new file?
2009-03-02 6:59 ` Björn Steinbrink
@ 2009-03-02 7:04 ` Jeff King
2009-03-02 13:05 ` Jay Soffian
0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2009-03-02 7:04 UTC (permalink / raw)
To: Björn Steinbrink; +Cc: Charles Bailey, Caleb Cushing, git
On Mon, Mar 02, 2009 at 07:59:49AM +0100, Björn Steinbrink wrote:
> Hm, how about this?
> git checkout --theirs file
> git mv file newname
> git checkout HEAD file # Can't use --ours here due to the mv
Actually, you can use --ours if you don't "git mv":
git checkout --theirs file
mv file newfile
git checkout --ours file
git add file newfile
One more command, but I think more obvious about what is going on (and I
think both are better than the other suggestions).
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: merge, keeping the remote as a new file?
2009-03-02 7:04 ` Jeff King
@ 2009-03-02 13:05 ` Jay Soffian
0 siblings, 0 replies; 7+ messages in thread
From: Jay Soffian @ 2009-03-02 13:05 UTC (permalink / raw)
To: Jeff King; +Cc: Björn Steinbrink, Charles Bailey, Caleb Cushing, git
On Mon, Mar 2, 2009 at 2:04 AM, Jeff King <peff@peff.net> wrote:
> On Mon, Mar 02, 2009 at 07:59:49AM +0100, Björn Steinbrink wrote:
>
>> Hm, how about this?
>> git checkout --theirs file
>> git mv file newname
>> git checkout HEAD file # Can't use --ours here due to the mv
>
> Actually, you can use --ours if you don't "git mv":
>
> git checkout --theirs file
> mv file newfile
> git checkout --ours file
> git add file newfile
>
> One more command, but I think more obvious about what is going on (and I
> think both are better than the other suggestions).
This is a superior answer as well because it avoids plumbing in a
situation where plumbing ought not be needed.
j.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-03-02 13:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-02 0:16 merge, keeping the remote as a new file? Caleb Cushing
2009-03-02 4:11 ` Jeff King
2009-03-02 6:36 ` Charles Bailey
2009-03-02 6:45 ` Jeff King
2009-03-02 6:59 ` Björn Steinbrink
2009-03-02 7:04 ` Jeff King
2009-03-02 13:05 ` Jay Soffian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).