Home > database >  Does Git generate the content of files in the Working Tree on the fly?
Does Git generate the content of files in the Working Tree on the fly?

Time:10-07

Say I have two files in the repo: a.txt and b.txt.

In branch hotfix, I updated b.txt. I commit the change (C1).

Then, in branch master, I updated a.txt. I commit the change (C2).

Then I merge hotfix into master. The resulting branch merge commit has two parents, pointing to C1 and C2. C1's tree object links to the blob for the updated b.txt. C2's tree object links to the blob for the updated a.txt. There is no single commit that contains a tree pointing to the latest version of a.txt and b.txt.

When master is checked out, are the files in the working tree generated on the fly from the different branches?

It is a similar situation when the same file was updated in two branches and subsequently merged successfully. There is no blob object in the database for the final merged version of the file. Is my understanding correct?

CodePudding user response:

When you merge into master, the master label is re-hung on the new merge commit, of a tree with the merge results, as with any commit that's a full snapshot. All files.

  •  Tags:  
  • git
  • Related