I do this:
$ git svn clone http://monsterdebugger.googlecode.com/svn/ -s --prefix=svn/ monsterdebugger
$ cd monsterdebugger
$ git branch -a
* master
remotes/svn/trunk
$ git co remotes/svn/trunk
Note: checking out 'remotes/svn/trunk'.
You are in 'detached HEAD' state. <And so on...>
I guess I'm not fully understanding what's going on under the hood here. Shouldn't remotes/svn/trunk be a tracking branch against the svn repo? Why did I end up with a detached head?
When you use the git checkout command to view a commit, you'll enter “detached HEAD state”. This refers to when you are viewing a commit that is not the most recent commit in a repository. Detached HEAD state is not an error nor is it a problem. When you are ready, you can navigate back to the HEAD in your repository.
If you want to keep changes made with a detached HEAD, just create a new branch and switch to it. You can create it right after arriving at a detached HEAD or after creating one or more commits. The result is the same. The only restriction is that you should do it before returning to your normal branch.
You must understand that any of your branches will not be affected if you ever get into a detached state . Now, the best way to reattach the HEAD is to create a new branch. We can do it as simple as git checkout -b <branch-name> . This will commit the changes from your temporary branch into the branch you need them.
You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. This detached head state occurs when a specific commit is checked out instead of a branch.
It's because it's a remote branch. You need to create a local branch for it, with something like:
git checkout -b my-trunk remotes/svn/trunk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With