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

Re: Binary files in a linear repository

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
Nov 2, 2009, 15:34 UTC
Message-ID
<20091102153428.GA4778@atjola.homenet>
In-Reply-To
<8470D32E-2CAA-4E3F-8BA0-B4578372A3C4@jump-ing.de>
On 2009.11.02 16:08:25 +0100, Markus Hitter wrote:
Show 20 quoted lines
> The situation I'm trying to solve is:
> 
> - A revision earlier than the latest one is checked out.
> 
> - Files of this earlier commit are modified.
> 
> - I want to record this earlier commit along with it's modifications
> as a new commit on top of master, ignoring intermediate commits:
> 
> com005  <-- master
> com004
> com003  <-- HEAD, files modified
> com002
> com001 (initial commit)
> 
> One solution to do this is to move all files somewhere else, check
> out master, deleting all checked out files, placing the moved away
> files back into place and committing the result as com006.
> Obviously, this is a pretty complex operation, just waiting to
> exploit coding mistakes. Additionally, this will be slow.

Instead of doing "git checkout com003", which detaches HEAD, you could do: git read-tree -u --reset com003

Which will update the index and working tree to reflect the contents of com003. The modify stuff, add, commit, done.

Show 7 quoted lines
> Now I'm thinking about a much simpler solution: Simply declare the
> current set of files as (a modified) master/com005 and commit them.
> A "cp $GIT_DIR/master $GIT_DIR/HEAD" followed by a commit would do
> it.
> 
> Now my question: Is it safe to tweak the files in $GIT_DIR this way
> or will this corrupt the repository?

Ignoring that $GIT_DIR/master is the wrong path, that 'cp' would (at best) act like detaching HEAD.

Björn
Previous: Markus HitterNext: Dmitry Potapov
Message 2 of 8 in “Binary files in a linear repository”
  1. Markus HitterNov 2, 2009
  2. Björn SteinbrinkNov 2, 2009
  3. Dmitry PotapovNov 2, 2009
  4. Björn SteinbrinkNov 2, 2009
  5. Dmitry PotapovNov 2, 2009
  6. Björn SteinbrinkNov 2, 2009
  7. Dmitry PotapovNov 2, 2009
  8. Björn SteinbrinkNov 2, 2009

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.