![]() I know this doesn't answer the question of how to modify the default branch on the remote repository, but it gives a clean answer on how to create a detached branch.Can someone explain a "tracking branch" as it applies to git? ![]() In truth, you can create a detached branch at any time by branching the initial commit in the repository, deleting its tree, adding your detached tree, then doing git commit -amend. If there were some git add's after the git rm then it wouldn't be necessary. The -allow-empty flag is only needed because we're committing an empty tree. The old HEAD commit doesn't get deleted by git-gc because refs/heads/master still points to it. But the current HEAD doesn't have a parent as it's the initial commit in the repository, so the new HEAD doesn't get one either, making them detached from each other. The "magic" here is that -amend causes git commit to create a new commit with the same parent as the current HEAD, then make HEAD point to it. Hey, presto! gitk -all will show master and trunk with no link between them. Git commit -amend -allow-empty -m "initial commit on detached trunk" Now we create our "real" branch (let's call it trunk in honour of SVN) and divorce it from master: git checkout -b trunk That gives us a master branch with a rude message (you may want to be more polite). ![]() Git commit -m "GO AWAY - this branch is detached from reality" You can create a detached master branch using only porcelain Git commands: git init
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |