Cheatography
https://cheatography.com
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/git-annex repo
mkdir /aNewRepo && cd /aNewRepo
Standard git repo init
git init .
Create git-annex1 repo
git-annex init . "R2D2-aNewRepo"
|
1 http://git-annex.branchable.com/
Suggest location-repo
name scheme for multi git repo setups
ie. R2D2-aNewRepo
Suggest location-repo-annex
name scheme for multi git-annex
repo setups
ie. R2D2-aNewRepo-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 cost 1
git config annex.queuesize 1024000
# Add metadata {a,c,m}time at first commit 2
git config annex.genmetadata true
# Change how git-annex looksup files 3
git config annex.backends {MD5E,WORM,..}
|
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 correlation against legacy media.
WORM is useful for fast imports and media files prone to changing metadata.
Indirect/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 deficiencies 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-annex's safety in ensuring the availability of a file.
Helpful Aliases
alias ga='git-annex'
alias gaa='git-annex add'
alias gas='git-annex sync'
alias gag='git-annex get'
alias gad='git-annex drop'
alias gal=git-annex unlock'
alias gau='git-annex unused'
alias gam='git-annex move'
alias gac='git-annex copy'
alias gaf='git-annex fsck'
alias gai='git-annex info'
alias gaw='git-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 work 1
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/Torrent Sources
alias ga='git-annex'
Use git-annex to add afile from the web 1
ga addurl http://fqdn/afile --file afile
# Add an URL to a file after the fact
git-annex addurl afile http://fqdn/afile
# Download/Add the contents of a torrent
ga addurl http://fqdn/a.torrent
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 "XWING-aNewRepo"
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/usb/aNewRepo
|
|
|
cp/mv/drop/find on remotes
cd ~/aNewRepo
Copy from this repo to a remote
git-annex copy afile --to XWING-aNewRepo
# Moves a file from this repo to a remote
git-annex move afile -t XWING-aNewRepo
Copy to this repo from a remote
cd /mnt/usb/aNewRepo
git-annex move bfile --from R2D2-aNewRepo
#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 management.
Sync Repos
Sync repo metadata - No content
cd /mnt/usb/aNewRepo
git-annex sync R2D2-aNewRepo
Sync metadata and content
git-annex sync R2D2-aNewRepo --content
|
Extra
# Tell git-annex to not rely on a repo 1
git-annex untrust C3PO-aNewRepo
Tell a repo is no longer available
git-annex dead JABBA-aNewRepo
|
1 We all know C3PO is flaky. git-annex by default only semi-trusts a repo. You can use this with remotes using direct mode, cloud storage, etc.
Repo maintenance
# Show git-annex information
git-annex info
# Fsck git-annex repo
git-annex fsck
Do git garbage collection
git gc
# Show unused objects in the repo 1
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/Branches/Views [To Do]
Add git-annex to existing git repos [To Do]
|