Skip to content

Instantly share code, notes, and snippets.

@ifnull
Last active October 26, 2020 00:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifnull/5761255 to your computer and use it in GitHub Desktop.
Save ifnull/5761255 to your computer and use it in GitHub Desktop.
git add alias for git annex that excludes selected file extensions from master and adds them to annex.
#######################
# Setup
#######################
mkdir annex-test
cd annex-test
git init
git annex init master
#######################
# Fab setup task
#######################
git config --local core.excludesfile ./.gitignore_large_binaries
git config --local alias.a '! sh ./git-add.sh'
#######################
# git a (git-add.sh)
#######################
# Generate annex include arg from .gitignore_large_binaries
include_str="--include='.lazy'";
while read line
do
if [[ "$line" != *"#"* ]] && [[ "$line" != "" ]]; then
include_str="$include_str --or --include=${line}";
fi
done < "./.gitignore_large_binaries"
# git annex add
git config --local core.excludesfile ./.gitignore;
git annex add $1 $include_str;
# git add
git config --local core.excludesfile ./.gitignore_large_binaries;
git add $1
@leviwheatcroft
Copy link

very helpful.. thanks. I'm clueless about bash scripts, but I had to change the double square brackets to singles like this:

if [ "$line" != *"#"* ] && [ "$line" != "" ]; then

@mbroadhead
Copy link

There is support for something like this in newer versions of git-annex.
See: https://git-annex.branchable.com/tips/largefiles/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment