Show Menu
Cheatography

git-annex Cheat Sheet (DRAFT) by

git for distributed binary file tracking

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Create a new git/gi­t-annex repo

mkdir ~/aNewRepo && cd ~/aNewRepo

Standard git repo init
git init .

Create git-annex1 repo
git-annex init . "­R2D­2-a­New­Rep­o"
1 http:/­/gi­t-a­nne­x.b­ran­cha­ble.com/
Suggest
locati­on-repo
name scheme for multi git repo setups
ie.
 R2D2-a­NewRepo

Suggest
locati­on-­rep­o-annex
name scheme for multi
git-annex
repo setups
ie.
R2D2-a­New­Rep­o-Annex

Customizations

Override global git config (optional)
cd ~/aNewRepo

git config user.name name

git config user.email email

# Speed up large commits at memory cost1
git config annex.q­ue­uesize 1024000

# Add metadata {a,c,m­}time at first commit2
git config annex.g­en­met­adata true

# Change how git-annex looksup files3
git config annex.b­ac­kends {MD5E,­WOR­M,..}
1 Default is 102400
2 Filesystem metadata can only be added during initial commit
3 Lots of other hashes to include SHA1, SHA256E(default).
MD5E is useful for correl­ation against legacy media.
WORM is useful for fast imports and media files prone to changing metadata.

Indire­ct/­Direct Mode

Use git-annex in direct mode
git-annex direct

# Use git-annex in indirect mode
git-annex indirect
Default is indirect mode.
Direct mode is used when a filesystem can't support sym links like FAT32 or when operating in a Windows OS.
NTFS/exFAT can still be used.
OSX might cover FAT32 defici­encies and work in indirect mode.
git-annex repos can be switched between direct and indirect at will.
Operating in direct mode takes away some of git-an­nex's safety in ensuring the availa­bility of a file.

Helpful Aliases

alias ga='gi­t-a­nnex'

alias gaa='g­it-­annex add'

alias gas='g­it-­annex sync'

alias gag='g­it-­annex get'

alias gad='g­it-­annex drop'

alias gal=gi­t-annex unlock'

alias gau='g­it-­annex unused'

alias gam='g­it-­annex move'

alias gac='g­it-­annex copy'

alias gaf='g­it-­annex fsck'

alias gai='g­it-­annex info'

alias gaw='g­it-­annex whereis'
 

File Management (indirect mode)

# Use
git-annex
instead of
git
1
git-annex add afile

Unlock a file for editing
git-annex unlock afile && echo ' ' >> afile

git mv afile bfile

git rm bfile

git commit -a -m "­commit msg"
1 Faster for large binary files

File Management (direct mode)

# git add/rm/mv will not work in direct mode
git-annex add afile

mv afile bfile

rm bfile

# git commit will not work in direct mode
# Use git-annex sync in lieu of git commit
git-annex sync -m "­commit msg"

Undo change as
git revert
will not work1
git-annex undo afile
1 Use with
--depth
to revert to earlier versions of file
Use of
git-annex sync
` is crucial in direct mode

Web/To­rrent Sources

alias ga='gi­t-a­nnex'
Use git-annex to add afile from the web1
ga addurl http:/­/fq­dn/­afile --file afile

# Add an URL to a file after the fact
git-annex addurl afile http:/­/fq­dn/­afile

# Downlo­ad/Add the contents of a torrent
ga addurl http:/­/fq­dn/­a.t­orrent

Add the contents of magnet link
ga addurl magnet­?....
1 If --file is not specified, the filename is appended to the fqdn. Not usually desired.

Adding remotes

cd /mnt/usb

Standard git clone
git clone ~/aNewRepo

cd aNewRepo

# Init git-annex with a unique name
git-annex init "­XWI­NG-­aNe­wRe­po"

Standard git remote config in new USB repo
git remote add R2D2 ~/aNewRepo

Std git remote config from origin repo
cd ~/aNewRepo

git remote add XWING /mnt/u­sb/­aNe­wRepo
 

cp/mv/­dro­p/find on remotes

cd ~/aNewRepo

Copy from this repo to a remote
git-annex copy afile --to XWING-­aNe­wRepo

# Moves a file from this repo to a remote
git-annex move afile -t XWING-­aNe­wRepo

Copy to this repo from a remote
cd /mnt/u­sb/­aNe­wRepo

git-annex move bfile --from R2D2-a­NewRepo

#Removes file from current repo only2
git-annex drop afile

Find who has a copy of a file
git-annex whereis afile
1 Checks against
numcopies

2Checks against
numcopies
. Use for space manage­ment.

Sync Repos

Sync repo metadata - No content
cd /mnt/u­sb/­aNe­wRepo

git-annex sync R2D2-a­NewRepo

Sync metadata and content
git-annex sync R2D2-a­NewRepo --content

Special Remotes (To Do)

Extra

# Tell git-annex to not rely on a repo1
git-annex untrust C3PO-a­NewRepo

Tell a repo is no longer available
git-annex dead JABBA-­aNe­wRepo
1 We all know C3PO is flaky. git-annex by default only semi-t­rusts a repo. You can use this with remotes using direct mode, cloud storage, etc.

Repo mainte­nance

# Show git-annex inform­ation
git-annex info

# Fsck git-annex repo
git-annex fsck

Do git garbage collection
git gc

# Show unused objects in the repo1
git-annex unused
1 These are objects that have not been dropped, but removed from a branch. Might want for archival reasons. Best to copy to an archival remote like bup.

Tags/B­ran­che­s/Views [To Do]

 

Add git-annex to existing git repos [To Do]