this post was submitted on 06 Mar 2024
29 points (91.4% liked)

Git

2632 readers
2 users here now

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Resources

Rules

  1. Follow programming.dev rules
  2. Be excellent to each other, no hostility towards users for any reason
  3. No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

founded 1 year ago
MODERATORS
 

Story time...

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 6 months ago* (last edited 6 months ago) (1 children)

Every commit lists one or more parents, possibly several parents, like 8 parents. These commits thus form a graph structure.

Branches and labels are just references to commits in this graph structure; they are commit alias, just a name that references a specific commit. Branches and tags are the same, except by convention the CLI will move branches when you commit to a branch, but tags are not moved by the CLI.

(Commits may have many names, they have their commit ID, and they may also be named by a branch or tag. Commit IDs are hashes of the contents of the commit. This ensures, cryptographically, that a commit and it's ID can never change.)

Git never deletes a commit that is less than 90 days old. If you commit something, rest assured your work is in there somewhere, it's just that no mortal being may be able to find it. Deleting a branch removes a reference to a commit, but the commits in the branch are still there. The GUI tools usually hide commits that are not part of a branch, but you can see them using "reflog" related commands.

[–] [email protected] 3 points 6 months ago

possibly several parents, like 8 parents

Fun fact. Such merges with more than 2 parents are called 'octopus merges'. The Linux repo has a single merge with 66 parents that Torvalds named the 'Cthulhu merge'.

Git never deletes a commit that is less than 90 days old.

On its own, that is. Not if you do a git gc.

Deleting a branch removes a reference to a commit, but the commits in the branch are still there.

but you can see them using “reflog” related commands

Reflog - one of the most underrated git commands that has the potential to save your life some day. At least one team member must learn it.