Re: How to create independent branches

From: <colin@horizon.com>
Date: 2006-04-09 09:15:20
  669  git-symbolic-ref HEAD refs/heads/slave
  670  echo "ref: refs/heads/master" > .git/HEAD
  671  git-symbolic-ref HEAD refs/heads/slave
  672  git add bar

> Another question. I'd like to create a totaly independent branch (like
> the "todo" branch in git). Is there a more user friendly way than doing
> 
> git-checkout -b todo
> rm .git/refs/heads/todo
> rm .git/index
> rm <all_files_in_your_workdir>
> 
> ... hack hack hack ...
> git-commit -a
> 
> I looked all over the docs, but can't find anything obvious.

If I undertstand, you basically want to create a second
initial commit, so you have two trees in your repository.

Well, an initial commit is just a commit object with no parents.

Try:
- Set up the workdir the way you want.  You have to git-add
  any newly added files, but git-update-index (called by
  git-commit -a) will remove from the index any files
  removed from the working directory, so you don't have to
  worry about those.
- Make sure refs/heads/todo doesn't exist
- "git-symbolic-ref HEAD refs/heads/todo"
  This makes HEAD a symlink (well, symref) to refs/heads/todo,
  which doesn't exist.
- git-commit -a
  Since the HEAD link doesn't exist, this does an initial
  commit.

It's not supremely user friendly, because multiple initial commits can
lead to problems down the road trying to merge, so you'd better know what
you're doing.

Another option is to just set up a second working directory, with a
shared object store, and do the checkin from there.  You can have the
.git/refs directories shared (via a symlink) or not.  If they're not
shared, you can later make them shared by copying over the relevant refs.


Oh, yes, note that if you fat-finger the "git-symbolic-ref HEAD" command,
any attempts to fix it will complain "not a git repository".
That's because a reference to refs/heads/ in HEAD is how git
identifies a repository.  "echo ref: refs/heads/master > .git/HEAD"
will fix it.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Sun Apr 09 09:16:20 2006

This archive was generated by hypermail 2.1.8 : 2006-04-09 09:16:34 EST