开发者

git problem - got detached from branch

Accidently I got detached from my application br开发者_如何学Canch:

Not currently on any branch. nothing to commit (working directory clean)

How can I return to the branch?


Try:

git checkout master

... or whatever branch you were previously on. To give some further explanation:

One of the most common uses of git checkout is to switch from one branch to another. e.g. git checkout experiment, git checkout master. However, you can also give it the name of a tag, or the SHA1 sum (object name) of a commit - in those cases, git will change HEAD (which normally points to a branch, indicating that that's your current branch) to point to that tag or commit. This is known as "detached HEAD" or "not being on a branch" - the main difference is that if you create commits when you're in detached HEAD mode, they won't advance a branch, so they're easier to lose track of.

However, this is a very useful thing to be able to do when you want to look at the state of your repository at some random point in the past. (e.g. jumping around in this way is often the first step of trying to find the last good commit for (the awesome) git bisect.)


git checkout master

Or any other branch you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜