0

Lets say I have a local repository named 'ABC" having a text file. I add 2 lines to the text file, and commit it. Lets call it "Commit A". Then I add 2 more lines to it and commit it. Lets call it "Commit B".

Will Commit B have the original text in text file and all the 4 new lines added, or just the 2 lines added in Commit B?

If I branch from Commit B, will the new branch have the original text and the 4 lines added, or just the 2 lines added in Commit B?

Spires
  • 167
  • 1
  • 2
  • 8
  • as far as im aware, when you commit a change, it updates your local repository. so making further changes/commits will update it relative to the previous state of the file – Brandon Bailey May 09 '19 at 11:01
  • 1
    You probably should think of a commit as a complete snapshot of your working directory. It is efficiently stored, but should not be your concern. If you want to dig deeper you can start with [Git Objects](https://git-scm.com/book/en/v1/Git-Internals-Git-Objects) – Micha Wiedenmann May 09 '19 at 11:04

1 Answers1

0

In layman terms, a commit is like a change set or a snapshot of your repo. Please check this answer for more details.

In your example, when you checkout a branch from Commit B, the branch will have commit B and its all past commits. Hence the new branch will have original text and 4 lines added.

Krantisinh
  • 1,579
  • 13
  • 16