Git

git is a Fast Distributed Version Control System (DVCS).

I wish I understood git better, but in spite of your help, I still don't have a proper understanding, so this may take a while.

-- Brian Kernighan, Awk Unicode announcement {2022 05 25}

See Also

git timestamps
RJM 2010-10-05: A page regarding an attempt to allow timestamp preservation of files

Criticism

I don't think trying to understand any other VCS in terms of git is a good idea. Git is so horribly unintuitive and dependent on its internal data structure model that it's a losing proposition.
- mst, on git and fossil, Tcl Chatroom, 2013-12-15

Critique

Why SQLite Does Not Use Git
10 things I hate about Git , Steve Bennett, 2012-02-24
The most damning point is number 7, Unsafe Version Control. A bad actor can irrevocably destroy the contents of a repository. Fossil doesn't have this hole.

Lore

A Git Origin Story {Zack Brown} {2018 07 27}
How and why git came to be.

Packages

lg2
Tcl bindings to the libgit2 library.

Tools

gitk
a history visualization tool written in Tcl/Tk.
fossil2git
Support scripts to maintain a system for mirroring a set of fossil repositories to one or more git repositories.
mug
A Teacup workalike that can download git repositories.

Description

Git is a distributed version control system created by Linus Torvalds over the course of a few weeks for developing the Linux kernel after Larry McVoy revoked the custom license for BitKeeper for the project in response to an attempt by Andrew Tridgell to reverse-engineer the BitKeeper network protocols. It uses the filesystem as its database, and outperforms every other distributed version control system in terms of speed.

In git, a branch is named a sequence change sets. Each change set is represented by a commit object that references the parent commit(s) and a tree object that describes the data in the directory hierarchy.

proc commit {} {
    upvar #0 $::current_branch current
    set current [list commit $::current_tree $current]
}

Each object is referenced by its sha1 hash. Thus, even if two different commit objects reference the same tree, that tree object is only store once. Since tree object is recursive, and each subtree is itself a tree object, each subtree is only stored once, even if it is part of multiple trees.

Git does not use reference counting to reclaim orphaned objects. Instead git-gc, the garbage collector git-gc deletes them when it is run. Until then, any object that has been deleted can be reclaimed.

Tips

[PYK} {2023 08 08}: Stashing changes one one branch, switching to another, and then applying the stashed changes may produce corrupt results if checkout that the stash was created under has not been merged into the branch that the stash is applied to. Therefore, only attempt to apply a stash on a branch that has merged the branch associated with the stash. Takeway: Git sort of sucks.

Discussion

Zarutian 2007-07-16: Can git be obtained or compiled into a multiplatform starkit? Hard when one has only an thumbdrive/ipod to store stuff.

Lars H 2008-06-05: Since it's a Unixy collection of many programs that do one thing each, I suspect this would be tricky (can't exec something in a vfs, can you?). Apparently there has been some work [L1 ] on turning it into a library, but that only got part of the way.

Makes me wonder, though… Could there be a semi-automatic way of turning a suite of C programs (like git, or at least the git plumbing) into a loadable extension which exposes each program as a Tcl command? (I expect one would have to do things like turning static C variables into fields of some dynamically allocated struct, to ensure reentrancy, but C is not my forte.)

FWIW, I later noticed that git has a concept of builtin command, with something rather close to a Tcl_CmdProc for every built-in subcommand of git. Probably not too hard to wrap manually, provided the built-in commands don't try to exec each other.


A thing that seems to be special about git is that it tracks content (e.g. procedure definitions) rather than files (as CVS, SVN, and Mercurial does). See A look back: Bram Cohen vs Linus Torvalds .