Thought & </code>


  • Home

  • Categories

  • About

  • Archives

  • Tags

  • Search

fix semantic-release always push a new major version

Posted on 2017-03-29   |   In JavaScript , package , npm   |  
fix semantic-release always push a new major version
Read more »

publish beta to npm

Posted on 2017-03-29   |   In JavaScript , package , npm   |  
how to publish beta version to npm
Read more »

import partial lodash feature to Typescript project

Posted on 2017-02-03   |   In TypeScript   |  
import partial lodash feature to Typescript project
Read more »

Angular2 Component Inheritance Summary

Posted on 2017-02-01   |   In Angular , Component   |  
Angular2 Component Inheritance Summary
Read more »

Commit on detached HEAD in Git

Posted on 2017-01-30   |   In Git , Tips   |  

First of all, don't commit on detached Head.

A "detached head" in git isn't the same as Mercurial's concept of a "head". Git has exactly one HEAD, which is just the currently checked-out commit. "Detached" just means that you don't currently have a branch checked out. So when you create a commit, it won't be associated with a branch, and it'll be lost when you checkout a different commit.

In Git, every commit that you care about should be reachable from some branch. There's no such thing as an "anonymous branch", which is why git warns you when committing on a detached head. Committing on a detached head is like allocating an object and then throwing away the pointer; it's possible, but almost never what you want to do. Remember, branches in git are lightweight and can be ephemeral. Just create a branch before committing so that you can find your commits again.

David@StackOverflowstackoverflow.com/a/16368880/667767

But it's too late, how to get it back ?

git reflog

It will show all commit with hash.

And create a new branch with the hash by

git branch <new-branch> <hash>

12…10
Sam Lin

Sam Lin

48 posts
37 categories
56 tags
RSS
© 2012 - 2017 Sam Lin
Powered by Hexo
NexT.Mist