Skip to content

Instantly share code, notes, and snippets.

@ifnull ifnull/gist:5761255
Last active Jan 24, 2016

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

leviwheatcroft commented Jan 24, 2016

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.