Re: [git-users] How to make a new branch with a portion of a branch?
On Sun, 17 Jun 2012 09:12:26 -0400 Eric Parent parent.eri...@gmail.com wrote: I've been working on a branch, say '2.1' and made a few commits on it. We've made a release and tagged the changeset at which the commit was produced, say 'tag2.1'. Development continued and a few more commits were made on that branch, the '2.1'. As the development goes, we think it would be a better idea to create a branch '2.2' that starts at the tag where the release was made and keep '2.1' only for the maintenance of that release. So here's what we have at the moment: (tag2.1) branch 2.1 : A - B - C - D - ...- K Here is what we would like to have: changesets C up to K to be on a branch 2.2 starting at 'tag2.1': (tag2.1) branch 2.1: A - B branch 2.2:- C' - D' -E' - ...- K' Any hints? 0) $ git checkout 2.1 1) $ git branch 2.2 2) $ git reset --hard tag2.1 This will: 1) Create a branch named 2.2 which points to the same commit the branch 2.1 currently does. 2) Make the 2.1 branch point to the same commit the tag tag2.1 points (effectively truncating the branch). You will have to forcibly push your 2.1 branch to your authoritative (central) repo if you have it. Your confusion about how to achieve what you want probably stems from the fact you think a branch is something special, while in git both tags and branches are simply references to a specific commit. What constitutes a line of history then is commit chanining: each commit references one or more parent commit(s) (except for the root commit in a repository which references nothing). Tags and branches are only different when it comes to committing (committing on a branch updates the reference while committing when you have a tag checked out does not update anything). -- 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.
[git-users] How to make a new branch with a portion of a branch?
Hi, I've been working on a branch, say '2.1' and made a few commits on it. We've made a release and tagged the changeset at which the commit was produced, say 'tag2.1'. Development continued and a few more commits were made on that branch, the '2.1'. As the development goes, we think it would be a better idea to create a branch '2.2' that starts at the tag where the release was made and keep '2.1' only for the maintenance of that release. So here's what we have at the moment: (tag2.1) branch 2.1 : A - B - C - D - ...- K Here is what we would like to have: changesets C up to K to be on a branch 2.2 starting at 'tag2.1': (tag2.1) branch 2.1: A - B branch 2.2:- C' - D' -E' - ...- K' Any hints? I tried a few things like: $ git checkout 2.1 $ git branch 2.2 'tag2.1' $ git reset --hard 'tag2.1' But that left me with an inconsistent repo... $ git checkout 2.1 $ git branch tmp 'tag2.1' $ git branch 2.2 'tag2.1' $ git rebase --onti 2.2 tmp 2.1 But did not leave me with the expected result either. Any hint is welcome. Cheers! -- - Eric -- Eric Parent mailto:parent.eri...@gmail.com blog: http://eric-parent.blogspot.com/ -- 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] How to make a new branch with a portion of a branch?
From: Eric Parent parent.eri...@gmail.com Sent: Sunday, June 17, 2012 2:12 PM Hi, I've been working on a branch, say '2.1' and made a few commits on it. We've made a release and tagged the changeset at which the commit was produced, say 'tag2.1'. Development continued and a few more commits were made on that branch, the '2.1'. As the development goes, we think it would be a better idea to create a branch '2.2' that starts at the tag where the release was made and keep '2.1' only for the maintenance of that release. So here's what we have at the moment: (tag2.1) branch 2.1 : A - B - C - D - ...- K Here is what we would like to have: changesets C up to K to be on a branch 2.2 starting at 'tag2.1': (tag2.1) branch 2.1: A - B branch 2.2:- C' - D' -E' - ...- K' Any hints? One option, for a small repo/team, is to rename branch 2.1 to branch 2.2, and then start a 'new' branch 2.1 from the tag 2.1. This makes your local repo look like what you are wanting. git branch (-m | -M) [oldbranch] newbranch git branch [--set-upstream | --track | --no-track] [-l] [-f] branchname [start-point] However this does break history for any remeote repo, or work colleagues, so you would have to force update the remote repo and send colleagues a an apologetic update message. You will want to ensure that the tracking is correct after your update, but it's not a problem. Philip I tried a few things like: $ git checkout 2.1 $ git branch 2.2 'tag2.1' $ git reset --hard 'tag2.1' But that left me with an inconsistent repo... $ git checkout 2.1 $ git branch tmp 'tag2.1' $ git branch 2.2 'tag2.1' $ git rebase --onti 2.2 tmp 2.1 But did not leave me with the expected result either. Any hint is welcome. Cheers! -- - Eric -- Eric Parent mailto:parent.eri...@gmail.com blog: http://eric-parent.blogspot.com/ -- 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.