Files
wiki/Automatic_Git_Commits.md

41 lines
2.3 KiB
Markdown

---
title: Automatic Git Commits
description: A simple set of scripts to enable a Git commit & push whenever entering a tracked directory
published: true
date: 2022-04-30T20:10:22.327Z
tags: git, maintanence
editor: markdown
dateCreated: 2021-09-02T08:23:55.501Z
---
# Automatic Git Commits
> This techique is being phased out from Takahe - I didn't like it for home use. However, it is useful and may prove useful again - hence this page.
{.is-warning}
Created for a non-Git savvy folk at work, the Takahe runs a pair of elegant Git auto commit scripts - the `GitDaemon` and the `GitUpstreamer`. After some modification, below is an outline on how these scripts work.
The first foothold is under the shell's profile - in our case, each user's `~/.zshrc` file (you *are* using [ohmyzsh](https://ohmyz.sh/), right?). If you look at the Environment Variables section at the bottom, you'll find the following:
```
### Environment Variables ###
export SCRIPTS="/home/shmick/Scripts"
source "$SCRIPTS/GitDaemon"
```
The [Git Daemon](https://git.pukeko.xyz/shmick/scripts/src/branch/master/GitDaemon) script is a replacement that latches onto the `cd` command - it first executes normal `cd` and then finds out whether the directory is under Git.
The [Git Upstreamer](https://git.pukeko.xyz/shmick/scripts/src/branch/master/GitUpstreamer) is what actually does the auto-commit - simply by quering the `git` command's output and committing to the set remote. This, of course, relies on a working set up remote.
You need to be aware of the following:
- The scripts only run on directories with a file named .autocommit. Git is common, and I want to be in control of what goes upstream, to avoid awkward situations.
- The scripts adds all files in the folder, and thus relies on a proper .gitignore file. If you had not explicitly ignored it - they will commit it!
- The scripts' only toggle is via the shell profile. No shell profile - no scripts.
# Under Git Automatic commits
- [Shells](https://git.pukeko.xyz/shmick/shells)
- under `/home/` and `/etc/zsh`
- [Docker compose files](https://git.pukeko.xyz/shmick/docker)
- Excluding Grocy, the Minecraft server, Pi-Hole and Portainer
- [Linux Kernel configs](https://git.pukeko.xyz/shmick/kernel-confs) (This doesn't really matter - I put them there, but whatever)