Skip to content

Instantly share code, notes, and snippets.

@vonHartz
Last active June 7, 2021 15:23
Show Gist options
  • Save vonHartz/2e21ffa4db8bf2089eea5d30e06989bb to your computer and use it in GitHub Desktop.
Save vonHartz/2e21ffa4db8bf2089eea5d30e06989bb to your computer and use it in GitHub Desktop.
Push git ignored folder to subtree branch
# based on https://stackoverflow.com/a/40178818/11051330
STATUS="$(LC_ALL=C git status)"
DOCSDIR="docs/_build/"
if [[ $STATUS == *"nothing to commit, working tree clean"* ]]
then
awk -vLine="$DOCSDIR" '!index($0,Line)' ./.gitignore
git add .
git commit -m "Edit .gitignore to publish docs"
git subtree push --prefix $DOCSDIR/html/ origin gh-pages
git reset HEAD~
git checkout .gitignore
else
echo "Need clean working directory to publish"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment