Skip to content

Instantly share code, notes, and snippets.

@olitreadwell
Last active November 5, 2021 09:06
Show Gist options
  • Save olitreadwell/ab7630f6b9fad3746547a83efe74ca51 to your computer and use it in GitHub Desktop.
Save olitreadwell/ab7630f6b9fad3746547a83efe74ca51 to your computer and use it in GitHub Desktop.
new-branch-and-auto-commit
#!/bin/zsh
git reset
mkdir -p ~/code/tmp/delete-me/
secondsInterval=20
branchName=`date +"%Y%m%d%H%M%S%Z"`
commitDateTime=`date +"%Y-%m-%d %T%Z"`
(git ls-files --modified --others --exclude-standard | grep . > /dev/null) && git add . && git stash
git checkout main && git pull
git checkout -b $branchName && git push
git branch --set-upstream-to=origin/$branchName $branchName
git stash pop
watch -n $secondsInterval ": > ~/code/tmp/delete-me/.${branchName}.txt ; echo "$(date +"%Y-%m-%d %T%Z")" > ~/code/tmp/delete-me/.${branchName}.txt; git pull && (git ls-files --modified --others --exclude-standard | grep . > /dev/null) && { git add . ; git commit -F ~/code/tmp/delete-me/.${branchName}.txt ; git push; }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment