git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: how to combine two clones in a collection

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 11, 2007, 18:37 UTC
Message-ID
<Pine.LNX.4.64.0707111929120.4516@racer.site>
In-Reply-To
<20070711181301.GA26815@piper.oerlikon.madduck.net>
Hi,
On Wed, 11 Jul 2007, martin f krafft wrote:
Show 9 quoted lines
> also sprach robin:
> > And the simplest way to create an new indpendent branch:
> 
> > echo ref: refs/heads/newbranch >.git/HEAD
> > Then prepare the content and commit like you used to do.
> 
> I am a little uneasy about touching files in .git with non-git
> tools, but everyone seems to be doing it, so I guess it's okay, and
> it make git a lot more powerful too.
You can achieve the same with
	git symbolic-ref HEAD refs/heads/newbranch
There.  No editing in .git/.
Show 11 quoted lines
>   piper:~> echo ref: refs/heads/newbranch >| .git/HEAD
>   piper:~> git status
>   # On branch newbranch
>   #
>   # Initial commit
>   #
>   # Changes to be committed:
>   #   (use "git rm --cached <file>..." to unstage)
>   #
>   #       new file: date
>   #
However, this is much easier without Git commands:
	rm .git/index

Of course, you can remove all files one by one, but that is certainly not easier:

	git ls-files --cached -z | xargs -0 git rm --cached

But then, you really can learn from both examples: .git/index contains references to the objects which are staged (in Git speak: "in the index"). Git plays nicely when that file is missing, and assumes the index to be empty.

With "git ls-files --cached", you can list the files which are in the index, and with "git rm --cached", you remove the file _only_ from the index, but keep it in the working tree (if it is there). The options "-z" and "-0" are only to separate the names by NUL instead of newlines, to allow funny file names, too.

If a few more people ask for that feature, we could enhance the semantics of "git branch" and "git checkout" to interpret the empty string similar to "git push <repo> :<name>".

Ciao, Dscho

Previous: martin f krafftNext: martin f krafft
Message 14 of 16 in “how to combine two clones in a collection”
  1. martin f krafftJul 9, 2007
  2. Linus TorvaldsJul 10, 2007
  3. martin f krafftJul 10, 2007
  4. Junio C HamanoJul 10, 2007
  5. martin f krafftJul 10, 2007
  6. Martin LanghoffJul 10, 2007
  7. Linus TorvaldsJul 10, 2007
  8. martin f krafftJul 10, 2007
  9. Brian GernhardtJul 10, 2007
  10. Kalle PokkiJul 10, 2007
  11. Brian GernhardtJul 10, 2007
  12. Robin RosenbergJul 10, 2007
  13. martin f krafftJul 11, 2007
  14. Johannes SchindelinJul 11, 2007
  15. martin f krafftJul 11, 2007
  16. Jakub NarebskiJul 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.