How to create a new branch based on a tag?

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

How to create a new branch based on a tag?

From: Ben Lau <hidden>
Date: 2016-06-15 22:42:09

Hi,

   I would like to create a branch of my own work based on a specific 
kernel version(i.e
v2.6.11). I tried with:

 > git-branch my2.6.11 v2.6.11
error: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a 
commit
fatal: Needed a single revision

  As v2.6.11 is a tree object(tag), git-checkout and git-branch could 
not process it. The
only way I know is using git-read-tree to fetch v2.6.11 content into 
current index and start
a branch based on it. Is there any simpler method?

Thanks!

Re: How to create a new branch based on a tag?

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:42:09

On 10/22/05, Ben Lau [off-list ref] wrote:
Hi,

   I would like to create a branch of my own work based on a specific
kernel version(i.e
v2.6.11). I tried with:

 > git-branch my2.6.11 v2.6.11
error: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a
commit
fatal: Needed a single revision
What you're after is

   git-rev-parse --verify <tagname>^0  > .refs/heads/mynewbranch

"branches" are very lightweight -- it's a ref containing the SHA1 of
the commit you want it to be at. So if you find the SHA1 of the commit
in gitk or wherever, just

  echo SHA1 > .refs/heads/mynewbranch

and you're sorted. Do git-checkout to switch to it.

cheers,


martin

Re: How to create a new branch based on a tag?

From: Ben Lau <hidden>
Date: 2016-06-15 22:42:09

Martin Langhoff wrote:
On 10/22/05, Ben Lau [off-list ref] wrote:
 
quoted
Hi,

  I would like to create a branch of my own work based on a specific
kernel version(i.e
v2.6.11). I tried with:
quoted
git-branch my2.6.11 v2.6.11
error: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not a
commit
fatal: Needed a single revision
   
What you're after is

  git-rev-parse --verify <tagname>^0  > .refs/heads/mynewbranch

"branches" are very lightweight -- it's a ref containing the SHA1 of
the commit you want it to be at. So if you find the SHA1 of the commit
in gitk or wherever, just

 echo SHA1 > .refs/heads/mynewbranch

and you're sorted. Do git-checkout to switch to it.

cheers,


martin
 
The command complains:

   >git-rev-parse --verify v2.6.11^
   error: Object 5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c is a tree, not 
a commit
   fatal: Needed a single revision

I think it need another way to convert a tag/tree object into a commit ?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help