简体   繁体   中英

git problem - got detached from branch

Accidently I got detached from my application branch:

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. eg 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. (eg 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

或者你想要的任何其他分支。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM