A Simple Shell Script To Commit And Push Automatically
Download the git-auto
file
$ chmod +x git-auto
./git-auto
# Auto run on opening logseq on linux
# Modify logseq desktop entry, e.g in /usr/share/applications/logseq-desktop.desktop
Exec=/bin/sh -c "/path/to/git-auto -d /path/to/logseq -pr & bg=$!; logseq; kill $bg"
Default behaviour:
- The script will exit if there is already another instance is running, use
-a
to bypass this. - If it is interrupted before the next commit/push interval, the current changes will not be committed/pushed. Use
-e
to always make a final commit/push upon exit.
More samples:
## git-auto ;; use current script dir as git dir, and auto commit, not push.
## git-auto -d /path/to/your/note's/dir ;; set git dir
## git-auto -i 30 -p ;; set interval seconds
## git-auto -m "Commit from desktop" ;; set commit message for all commits
## git-auto -b main -p ;; set git branch
## git-auto -s origin -p ;; set remote server
## git-auto -p ;; auto commit and push
## git-auto -r ;; auto commit, rebase, merge, push
## git-auto -o -p;; execute once
Before you proceed to use the git-auto
file, please make sure Git installed, otherwise please download Git and install it.
-
Just click 'yes' all the way down and you will find
Git Bash
icon in thestart
. -
Open
PowerShell
Download the target repository if you don't have it locally yet:
git clone [your_repo_url]
cd [your_repo_location]
For those who don't yet have a repository on Github, please refer to https://docs.github.com/en/github/getting-started-with-github/create-a-repo.
- Usage
Download the Start-GitAutoCommit.ps1
file, and run
.\Start-GitAutoCommit.ps1
More samples:
Start-GitAutoCommit # use current script dir as git dir, and auto commit, not push.
Start-GitAutoCommit -d /path/to/your/note's/dir # set git dir
Start-GitAutoCommit -p # auto commit and push
Start-GitAutoCommit -s origin -p # set remote server
Start-GitAutoCommit -b main -p # set git branch
Start-GitAutoCommit -i 30 -p # set interval seconds
Start-GitAutoCommit -o -p # execute once
Thanks for your work!
PowerShell Port, by @batkiz
Readme-CN.md & Git Bash docs, by @zhanghanduo
Copyright © 2020 Michael Wong
Distributed under the MIT License.