ContentLimitations

From Git SCM Wiki
Jump to: navigation, search

Git is a content tracker, where content is de facto defined as "whatever is relevant to the state of a typical sourcecode tree". Basically, this is just files' data and "executable" attribute.

By design, git cannot track other aspects of the filesystem, including:

  • File modes (except for the "executable" bit, and being symbolic link)
  • File ownership (commits, however, remember 'author' and 'committer' info)
  • File modification and access times (these are set to checkout time for files which are modified during checkout)
  • File ACLs and extended attributes
  • Hard links
  • Empty directories (although it is not a fundamental limitation, git just automatically removes empty directories and does not add empty directories)

There are some names which are considered special by git:

  • Arbitrary directories called ".git" (these contain the base of a repository),
  • Arbitrary directories containing a ".git" subdirectory with certain content (if "dir/.git" exists and seems to contain a valid head ref, then "git add dir" assumes that "dir" is a submodule)
  • Arbitrary files called ".gitignore" (these have special semantics)
  • Arbitrary files called ".gitattributes" (these have special semantics)

In general, it's best to consider any file or directory name beginning with ".git" as potentially special.

Consequentially, Git cannot be directly used as a general versioning solution for arbitrary files, such as home directories or "/etc". In principle, it is possible to add a layer above git to convert the above information into "content" that Git can track. A crude and inefficient example would be to "tar" the whole directory and track the tar file as a single blob.

Some of the above items can be represented by tree objects in a git repository, but such tree objects are difficult or impossible to create using the standard git tools.

There exist tools which either help git track full set of file modes etc., for example Metastore by David Hardeman (git://git.hardeman.nu/metastore.git). There also exists configuration versioning tool (APT for your config), based on git, named IsiSetup. There is also a tool to backup your home directory with git: gibak. See InterfacesFrontendsAndTools page.


Personal tools