-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.sh
More file actions
executable file
·44 lines (37 loc) · 1.14 KB
/
Copy pathcommit.sh
File metadata and controls
executable file
·44 lines (37 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# Function to check for unstaged changes and return their filenames
get_unstaged_files() {
git status --short | grep '^[A(\ M)?]' | awk '{print $2}' | grep -E '\.(cc|py)$'
}
unstaged_files=$(get_unstaged_files)
if [ -z "$unstaged_files" ]; then
echo "No unstaged files found."
exit 0
fi
for filename in $unstaged_files; do
read -p "Do you want to commit the file '${filename}' and then push it? (y/n): " choice
case "$choice" in
y|Y )
echo
echo "Adding file to staging and committing it locally..."
echo "------------------------------------------------"
echo
git add "$filename"
git commit -m "add ${filename}"
echo
echo "File '${filename}' has been added and committed locally."
echo "------------------------------------------------"
echo "Pushing the file to GitHub now..."
echo
git push
echo "------------------------------------------------"
echo "Success!!!"
;;
n|N )
echo "File '${filename}' has not been committed."
;;
* )
echo "Invalid choice. Skipping the file '${filename}'."
;;
esac
done