Checklist To Merge Feature-Branch Into Main With Tagging and Delete For Solo developer

Make Sure You’re On The Feature-Branch

git status

If files need to be staged

git add .

Then commit the files

git commit -m "commit message"

Then push the branch

git push origin feature-branch

Tag Feature-Branch and Backup Postgres - See Below For Scripts

tagbackup "message goes here"

Push tag to remote

git push origin --tags

Switch to main

git checkout main

Merge feature-branch to main

git merge --no-ff feature-branch

Do a merge tag

git_tag_dev "Merge of feature branch"

Push tag to remote

git push origin --tags

Push main to origin

git push origin main

Delete feature-branch on remote

git push origin --delete feature-branch

Delete feature-branch on local

git branch -d feature-branch

Create new feature-branch-2 off of main

git status (to make sure you're on main)

git checkout -b feature-branch-2

Do a first empty commit - see below for function

git_empty_commit

Push empty commit to origin with -u flag to set up tracking

git push -u origin feature-branch-2

Done

Scripts

git_tag_dev "Message goes here"

./.scripts2/dev_tag_and_backup.sh "my message here"

Git Shortcut Functions For .ZSHRC

Add to .zshrc or .bashrc

Git Tag Function

function git_tag_dev() {
  local now=$(date +"%Y%m%d-%H%M")
  local msg=${1:-"Dev checkpoint"}
  git tag -a "dev-${now}" -m "${msg}"
}

Git Empty Commit Function

function git_empty_commit() {
  local now=$(date +"%Y%m%d-%H%M")
  local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
  local msg=${1:-"Initial empty commit on ${branch} at ${now}"}

  if [ -z "$branch" ]; then
    echo "⚠️  Not in a Git repo"
    return 1
  fi

  git commit --allow-empty -m "${msg}"
}

Reload .zshrc

source .zshrc

Equivalent to

git tag -a dev-<date>-<time> -m "Merge of feature branch"


git commit --allow-empty -m "Initial empty commit on feature-branch-2"

Script to tag and backup databases in One Command

Add to .zshrc

alias tagbackup="./scripts/dev_tag_and_backup.sh"

Then in ./scripts/dev_tag_and_backup.sh

Add the following code:

#!/bin/bash

# Always run from repo root
cd "$(git rev-parse --show-toplevel)" || exit 1

# Timestamp
now=$(date +"%Y%m%d-%H%M")
tag_msg=${1:-"Dev checkpoint"}
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)

if [ -z "$branch" ]; then
  echo "⚠️  Not in a Git repo"
  exit 1
fi

# Git tagging
tag="dev-${now}"
git tag -a "$tag" -m "$tag_msg"
git commit --allow-empty -m "Empty commit for tag $tag on $branch"

# PostgreSQL backup
CONTAINER_NAME="postgres_db"
DB_NAME="postgres"
DB_USER="postgres"
BACKUP_DIR="$HOME/backups/postgres_backups"
BACKUP_FILE="$BACKUP_DIR/backup_${now}.sql"

mkdir -p "$BACKUP_DIR"
echo "🔄 Running Postgres backup..."
docker exec "$CONTAINER_NAME" pg_dump -U "$DB_USER" "$DB_NAME" > "$BACKUP_FILE"

# Clean old backups
find "$BACKUP_DIR" -type f -name "*.sql" -mtime +7 -exec rm {} \;

echo "✅ Dev tag '$tag' created and Postgres backup saved to $BACKUP_FILE"

Then just run

tag backup "message goes here"

Visit Emlekezik.com