Showing posts with label IaC. Show all posts
Showing posts with label IaC. Show all posts

Friday, October 30, 2026

Git and .gitignore

I posted a few days ago that I'd deployed Gitea (a git server).

I basically pushed my /opt/stacks directory to Gitea.

Well, I'm now finding that I pushed non-IaC files to my repos, and I'm only supposed to push IaC files (e.g., compose.yml files or any config files that I normally create/manipulate).  I discovered that many files were either plugins or gz files, for example...neither of those are IaC filetypes.  

Additionally, I realized that I should not push .env files (or any files that contain secrets/passwords) to Git.

I was not aware that I could filter out files/directories, nor was I aware of .gitignore until I researched how to exclude files.  

I also created .gitignore files within each stack, which, later on, I found wasn't optimal.  Instead of having a separate ignore file for each stack (e.g., /opt/stacks/wordpress and /opt/stacks/dockge), the more efficient method would be to place the ignore file at /opt/stacks, so I ended up redoing all of my repos.

A .gitignore file is just a hidden file to exclude files from being pushed to Gitea (or whatever Git solution you're using).

For example, my .gitignore contents on my hosted public server is:

# --- General Backups, Archives & Logs ---
*.tar.gz
*.gz
*.zip
*.bak
*.bak.*
*.old
*.10*
*.log
# --- App Data & Databases ---
**/data/
**/portainer-data/
pihole/etc-pihole/
pihole-old/etc-pihole/
# --- WordPress Core, Backups & Bloat ---
wordpress/wp-admin/
wordpress/wp-includes/
wordpress/*.php
!wordpress/wp-config-sample.php
!wordpress/.htaccess
!wordpress/index.php
wordpress/*.txt
wordpress/*.html
# --- WordPress Content / Plugins / Backups / Logs ---
wordpress/wp-content/uploads/
wordpress/wp-content/cache/
wordpress/wp-content/upgrade/
wordpress/wp-content/plugins/
wordpress/wp-content/themes/
wordpress/wp-content/bps-backup/
wordpress/wp-content/updraft/
wordpress/wp-content/wflogs/
wordpress/wp-content/wpo-cache/
# --- System & Temp Files ---
.DS_Store
.env

As I learn Git, I find that it can be very satisfying to track/truth my IaC files.

I've not yet used Git at work, although I've an account - I typically do not use IaC content for the work I'm currently doing, but I'm sure I'll eventually use IaC content to streamline my work.  The main concern for me is to learn best practices for IaC and Git.  I'm just hoping I'm not teaching myself bad habits now, to have to correct myself later on - definitely don't want mistakes to happen at work, either, which is why I'm practicing at home.