Re: [git-users] Forcing a push from one branch to another

2012-09-25 Thread Philip Oakley
  From: Chris Stankevitz 
  To: git-users@googlegroups.com 
  Sent: Tuesday, September 25, 2012 7:31 PM
  Subject: [git-users] Forcing a push from one branch to another


  Hello,


  If possible please humor me and attempt to answer this question:


  How do I make b look exactly like a using one commit?  Here is the manual 
approach:
Do you mean you want Branch 'b' drop its old line of development and become the 
same as Branch 'a'.
Or you want Branch 'b' to gain a fresh commit who's content is identical to 
that on the tip of Branch 'a', but it would have a different history?

In both case the top commit of b is the same, but the two variants would have 
different history.

There are a few different methods, and which one to use depends on what level 
of sophistication or plumbing commands you want.
At the plumbing level you can simply create a commit on 'b' that simply uses 
the top tree from 'a', then do a `reset --hard` to make your worktree match 
that commit. 


  - git checkout a.  Recursively copy all files in to /tmp
  - git checkout b
  - recursively copy all files from /tmp into cwd
  - git add [as appropriate]
  - git rm any files from cwd that are not in /tmp
  - git commit -am Made b look just like a



  Thank you,


  Chris

  -- 
  You received this message because you are subscribed to the Google Groups 
Git for human beings group.
  To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/z72DnZzvWyMJ.
  To post to this group, send email to git-users@googlegroups.com.
  To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
  For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.

  No virus found in this message.
  Checked by AVG - www.avg.com
  Version: 2012.0.2221 / Virus Database: 2441/5290 - Release Date: 09/24/12

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Forcing a push from one branch to another

2012-09-25 Thread Chris Stankevitz

On Tuesday, September 25, 2012 11:48:25 AM UTC-7, Philip Oakley wrote:

 Do you mean you want Branch 'b' drop its old line of development and 
 become the same as Branch 'a'.
 Or you want Branch 'b' to gain a fresh commit who's content is identical 
 to that on the tip of Branch 'a', but it would have a different history?


Philip,

Thank you for your help!

My intention is for branch 'b' to gain a single commit whose diffs result 
in branch 'b' looking just like 'a'.  I attempted to say this by describing 
a series of laborious steps in my original post.
  

 There are a few different methods


At this point, I'd be happy with whichever method will be easiest for you 
to type on this list.  Currently I am using the series of laborious steps 
in my original post.
 

 At the plumbing level you can simply create a commit on 'b' that simply 
 uses the top tree from 'a', then do a `reset --hard` to make your worktree 
 match that commit.


Unfortunately I am not skilled enough to translate this sentence into a 
series of git commands.  Could you please either refer me to the 
documentation for the top tree command (as you call it) or just type out 
the commands that might do what I want?

Thank you again,

Chris



-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/git-users/-/5T9mRBmV7nQJ.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



Re: [git-users] Forcing a push from one branch to another

2012-09-25 Thread Philip Oakley
From: Chris Stankevitz 
  To: git-users@googlegroups.com 
  Cc: Chris Stankevitz ; Philip Oakley 
  Sent: Tuesday, September 25, 2012 8:01 PM
  Subject: Re: [git-users] Forcing a push from one branch to another



  On Tuesday, September 25, 2012 11:48:25 AM UTC-7, Philip Oakley wrote:
Do you mean you want Branch 'b' drop its old line of development and become 
the same as Branch 'a'.
Or you want Branch 'b' to gain a fresh commit who's content is identical to 
that on the tip of Branch 'a', but it would have a different history?


  Philip,


  Thank you for your help!


  My intention is for branch 'b' to gain a single commit whose diffs result in 
branch 'b' looking just like 'a'.  I attempted to say this by describing a 
series of laborious steps in my original post.

There are a few different methods


  At this point, I'd be happy with whichever method will be easiest for you to 
type on this list.  Currently I am using the series of laborious steps in my 
original post.

At the plumbing level you can simply create a commit on 'b' that simply 
uses the top tree from 'a', then do a `reset --hard` to make your worktree 
match that commit.


  Unfortunately I am not skilled enough to translate this sentence into a 
series of git commands.  Could you please either refer me to the documentation 
for the top tree command (as you call it) or just type out the commands that 
might do what I want?
The place to look for those internal details is:
http://git-scm.com/book/en/Git-Internals-Git-Objects

Using it as a template we see that you should be able to use:
 
The master^{tree} syntax specifies the tree object that is pointed to by the 
last commit on yourmaster branch.

and

To create a commit object, you call commit-tree and specify a single tree SHA-1 
and which commit objects, if any, directly preceded it. Start with the first 
tree you wrote:

$ echo 'first commit' | git commit-tree d8329fyou'll write the other two commit 
objects, each referencing the commit that came directly before it:

$ echo 'second commit' | git commit-tree 0155eb -p fdf4fc3

You already have the tree on branch 'A', so it should be as simple as:

git update-ref refs/heads/B $(echo 'Copied from Branch A' | git commit-tree 
A^{tree} -p B)

Which is three steps in one:
1.   git commit-tree A^{tree} -p B# create the commit with branch B as the 
parent
2.   echo 'Copied from Branch A' |  # give it a message
3.   git update-ref refs/heads/B $(...)  # and update Branch B with the answer 
(sha1) from the commit created at 1.

I tested this on a simple dummy repo and it worked while I was on branch A. 

And Thanks for making me look properly ;-)


  Thank you again,


  Chris

-- 
You received this message because you are subscribed to the Google Groups Git 
for human beings group.
To post to this group, send email to git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.