mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 16:43:12 +02:00
Add push_files.sh
This commit is contained in:
parent
87d6bb0d97
commit
7d3bf7d56e
33
push_files.sh
Executable file
33
push_files.sh
Executable file
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user