From 7d3bf7d56e576c24dbc4307b2d3403337d87bc44 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Thu, 28 Nov 2024 17:51:36 +0100 Subject: [PATCH] Add push_files.sh --- push_files.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 push_files.sh diff --git a/push_files.sh b/push_files.sh new file mode 100755 index 00000000..8e162dc6 --- /dev/null +++ b/push_files.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Ensure the script exits on error +set -e + +# Check if we are inside a git repository +if ! git rev-parse --is-inside-work-tree &>/dev/null; then + echo "Not inside a Git repository." + exit 1 +fi + +# Loop until there are no untracked files +while true; do + # List untracked files and their sizes, sort by size + smallest_file=$(git ls-files --others --exclude-standard -z | xargs -0 du -b | sort -n | head -n 1 | awk '{print $2}') + + # Exit if no untracked files are found + if [ -z "$smallest_file" ]; then + echo "All untracked files have been processed." + break + fi + + # Add the smallest untracked file + git add "$smallest_file" + + # Commit the added file + git commit -m "Add $(basename "$smallest_file")" + + # Push the commit to the remote + git push + + echo "Processed: $smallest_file" +done