Skip to content

Instantly share code, notes, and snippets.

@pratikshrestha
Created August 21, 2023 02:29
Show Gist options
  • Select an option

  • Save pratikshrestha/5a924ea79391078175c8c1995071ba38 to your computer and use it in GitHub Desktop.

Select an option

Save pratikshrestha/5a924ea79391078175c8c1995071ba38 to your computer and use it in GitHub Desktop.
#!/bin/sh
old_ref=$1
new_ref=$2
branch_switched=$3
if [[ $branch_switched != '1' ]]
then
exit 0
fi
echo "---- POST CHECKOUT ----"
current_branch=$(git rev-parse --abbrev-ref HEAD)
hook_dir=$(dirname $0)
root_dir="$(pwd -P)"
info_dir="$root_dir/.git/info"
exclude_target='.gitignore'
if [[ -f "$root_dir/$exclude_target.$current_branch" ]]
then
echo "Prepare to use .gitignore.$current_branch as exclude file"
exclude_target=.gitignore.$current_branch
fi
cd "$info_dir"
rm exclude
#ln -s $exclude_target exclude
echo "Copy .gitignore.$current_branch file in place of exclude"
cp "$root_dir/$exclude_target" exclude
echo "--- POST CHECKOUT END ---"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment