Skip to content

Instantly share code, notes, and snippets.

@ADoebeling
Last active January 29, 2023 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ADoebeling/440564a254469c78eb73 to your computer and use it in GitHub Desktop.
Save ADoebeling/440564a254469c78eb73 to your computer and use it in GitHub Desktop.
Simple shellscript for updating .gitignore, auto-commit and push all changes to github
#!/bin/sh
# GIT Auto-Commit
#
# @author Andreas Doebeling <Kontakt@Doebeling.de>
# @copyright 1601.production siegler&thuemmler ohg
# @link http://www.1601.com
# @link http://xing.doebeling.de
# @version 0.2.230129_1ad
DIR="dir1/ dir2/"
GIT_AUTHOR="Script gitAutoCommit.sh by @ADoebeling <Webserver@Doebeling.de>"
GIT_SUBJECT="Auto-Update of $DIR (by gitAutoCommit.sh)"
GIT_MAXFILESIZE="30M"
LOG="$(pwd)/gitAutoCommit.sh.log"
COPYRIGHT="This commit was checked in by gitAutoCommit.sh
Author: Andreas Doebeling (@ADoebeling) <Kontakt@Doebeling.de>
Copyright: 2015 by 1601.production siegler&thuemmler ohg (@1601com)"
cd /path/to/www
echo "=====================================================" > $LOG
echo "Adding Wildcards to .gitignore" >> $LOG
date >> $LOG
echo "=====================================================" >> $LOG
echo "" >> $LOG
echo "" >> $LOG
echo "# Don't edit this file, it's generated automaticly" > .gitignore
echo "*.tmp" >> .gitignore
echo "Thumbs.db" >> .gitignore
echo "*.lnk" >> .gitignore
echo ".settings/*" >> .gitignore
echo ".project/*" >> .gitignore
echo ".idea/" >> .gitignore
echo "*.log" >> .gitignore
echo "*.zip" >> .gitignore
echo "*.tgz" >> .gitignore
echo "weblogs/*" >> .gitignore
echo "log/*" >> .gitignore
echo "cache/*" >> .gitignore
echo "tmp/*" >> .gitignore
echo "temp/*" >> .gitignore
echo "gitAutoCommit/*" >> .gitignore
echo "440564a254469c78eb73/*" >> .gitignore
echo "=====================================================" >> $LOG
echo "Adding pathes at .gitignore and add $DIR" >> $LOG
date >> $LOG
echo "=====================================================" >> $LOG
echo "" >> $LOG
echo "" >> $LOG
find $DIR -size +$GIT_MAXFILESIZE >> .gitignore
git add $DIR >> $LOG
git add .gitignore >> $LOG
echo "=====================================================" >> $LOG
echo "git status" >> $LOG
date >> $LOG
echo "=====================================================" >> $LOG
echo "" >> $LOG
echo "" >> $LOG
git status >> $LOG
echo "=====================================================" >> $LOG
echo "git commit & push" >> $LOG
date >> $LOG
echo "=====================================================" >> $LOG
echo "" >> $LOG
echo "" >> $LOG
git commit --author="$GIT_AUTHOR" -m "$GIT_SUBJECT" -m "$COPYRIGHT" >> $LOG
# Fixing ./ssh-permissions, destroyed by dF-fixowner
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
git config push.default simple
git push >> $LOG
#GIT_HASH=$(git log -1 --format="%H")
#DATETIME=$(date +%d.%m.%Y\ %H:%M)
#curl --data "
#{
#\"title\":\"Auto-Commit $DATETIME\",
#\"body\":\"Please check last commit $GIT_HASH\",
#\"assignee\":\"ADoebeling\"
#}" https://api.github.com/repos/$GIT_REPO/issues -u "$GIT_LOGIN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment