andornaut / gog

Link files to Git repositories

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gog - Go Overlay Git

Link files to Git repositories

  • gog can be used to manage "dotfiles" in ${HOME} or elsewhere on the filesystem
  • gog supports multiple Git repositories, which can be useful to separate personal and work files

Installation

Pre-compiled binary

Download one of the pre-compiled binaries from the releases page, and then move it onto your path: chmod +x gog-linux-amd64 && sudo mv gog-linux-amd64 /usr/local/bin/gog

Compile from source

Install dependencies:

git clone https://github.com/andornaut/gog.git
cd gog
make install

Getting started

# Clone a git repository and add a file to it
gog repository add dotfiles https://example.com/user/dotfiles.git
gog add ~/.config/foorc

# Gog moved `~/.config/foorc` into the default git repository ("dotfiles") and
# then created a symlink to it at its original location
ls -l ~/.config/foorc | awk '{print $9,$10,$11}'
> /home/example/.config/foorc -> /home/example/.local/share/gog/dotfiles/$HOME/.config/foorc

# Commit and push the changeset to make it available from elsewhere
gog git commit -am 'Add foo config'
gog git push

# Login to a remote machine and initialize the same git repository as above
ssh remote@example.com
gog repository add dotfiles https://example.com/user/dotfiles.git

gog apply

# Gog linked `~/.config/foorc` as above, while preserving any preexisting file at
# that location as ~/.config/.foorc.gog`
ls -l ~/.config/foorc | awk '{print $9,$10,$11}'
> /home/example/.config/foorc -> /home/example/.local/share/gog/dotfiles/$HOME/.config/foorc

Usage

gog --help

Link files to Git repositories

Usage:
  gog [command]

Available Commands:
  add         Add files or directories to a repository
  apply       Link a repository's contents to the filesystem
  git         Run a git command in a repository's directory
  help        Help about any command
  remove      Remove files or directories from a repository
  repository  Manage repositories

Flags:
  -h, --help                help for gog
  -r, --repository string   name of repository

Use "gog [command] --help" for more information about a command..

gog repository --help

Manage repositories

Usage:
  gog repository [command]

Available Commands:
  add         Add a git repository
  get-default Print the name or path of the default repository
  list        Print the names or paths of all repositories
  remove      Remove a repository

Flags:
  -h, --help   help for repository

Use "gog repository [command] --help" for more information about a command.

gog add --help

Add files or directories to a repository

Usage:
  gog add [paths...]

Flags:
  -h, --help                help for add
  -r, --repository string   name of repository

gog apply --help

Link a repository's contents to the filesystem

Usage:
  gog apply

Flags:
  -h, --help                help for apply
  -r, --repository string   name of repository to apply

Notes

gog add

If any of the path arguments to gog add begin with the current user's home directory, then this prefix is replaced with an escaped \${HOME} path component, and then the ${HOME} variable is expanded when gog apply is run.

gog apply

gog apply operates on a single repository at a time, but you can apply multiple repositories - even if they contain partially overlapping files.

for repoName in $(gog repository list | sort -r); do
  gog --repository ${repoName} apply
done

Configuration

You can use environment variables to customize some settings.

Environment variable Description
GOG_DEFAULT_REPOSITORY_NAME The repository to use when --repository NAME is not specified (default: the first directory in ${HOME}/.local/share/gog)
GOG_DO_NOT_CREATE_BACKUPS Do not create .gog backup files
GOG_HOME The directory where gog stores its files (default: ${HOME}/.local/share/gog)
GOG_IGNORE_FILES_REGEX Do not link repository-relative file paths that match this regular expression

Developing

See the Makefile.

About

Link files to Git repositories

License:MIT License


Languages

Language:Go 97.0%Language:Makefile 3.0%