{"thread":{"id":"3834","subject":"Re: How to create independent branches","startedAt":"2006-04-08T23:15:20Z","lastAt":"2006-04-08T23:15:20Z","messageCount":1,"participants":["colin@horizon.com"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"18486","messageId":"20060408231520.27044.qmail@science.horizon.com","threadId":"3834","inReplyTo":null,"subject":"Re: How to create independent branches","fromName":"","fromEmail":"colin@horizon.com","sentAt":"2006-04-08T23:15:20Z","receivedAt":"2006-04-08T23:15:20Z","isPatch":false,"sender":{"key":"colin@horizon.com","avatar":null},"body":"  669  git-symbolic-ref HEAD refs/heads/slave\n  670  echo \"ref: refs/heads/master\" > .git/HEAD\n  671  git-symbolic-ref HEAD refs/heads/slave\n  672  git add bar\n\n> Another question. I'd like to create a totaly independent branch (like\n> the \"todo\" branch in git). Is there a more user friendly way than doing\n> \n> git-checkout -b todo\n> rm .git/refs/heads/todo\n> rm .git/index\n> rm <all_files_in_your_workdir>\n> \n> ... hack hack hack ...\n> git-commit -a\n> \n> I looked all over the docs, but can't find anything obvious.\n\nIf I undertstand, you basically want to create a second\ninitial commit, so you have two trees in your repository.\n\nWell, an initial commit is just a commit object with no parents.\n\nTry:\n- Set up the workdir the way you want.  You have to git-add\n  any newly added files, but git-update-index (called by\n  git-commit -a) will remove from the index any files\n  removed from the working directory, so you don't have to\n  worry about those.\n- Make sure refs/heads/todo doesn't exist\n- \"git-symbolic-ref HEAD refs/heads/todo\"\n  This makes HEAD a symlink (well, symref) to refs/heads/todo,\n  which doesn't exist.\n- git-commit -a\n  Since the HEAD link doesn't exist, this does an initial\n  commit.\n\nIt's not supremely user friendly, because multiple initial commits can\nlead to problems down the road trying to merge, so you'd better know what\nyou're doing.\n\nAnother option is to just set up a second working directory, with a\nshared object store, and do the checkin from there.  You can have the\n.git/refs directories shared (via a symlink) or not.  If they're not\nshared, you can later make them shared by copying over the relevant refs.\n\n\nOh, yes, note that if you fat-finger the \"git-symbolic-ref HEAD\" command,\nany attempts to fix it will complain \"not a git repository\".\nThat's because a reference to refs/heads/ in HEAD is how git\nidentifies a repository.  \"echo ref: refs/heads/master > .git/HEAD\"\nwill fix it.\n"}]}