-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpush.sh
executable file
·37 lines (27 loc) · 842 Bytes
/
push.sh
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
#!/bin/bash
function commit_and_push() {
# Get arguments (optional)
repo_path="$1"
# Check if argument is provided
if [[ -z "$repo_path" ]]; then
echo "Usage: $0 <repo_path>"
exit 1
fi
# Change directory to the repository (optional)
# Uncomment the following line if you want to automatically change directory
# cd "$repo_path"
# Prompt for commit message
echo "Enter commit message:"
read commit_message
# Add all changes
git add -A
# Commit with custom message
git commit -m "$commit_message"
# Push to remote (assuming 'origin')
git push origin
echo "Successfully committed and pushed with message: '$commit_message'"
}
# Get repository path from command line (optional)
repo_path="$1"
# Call the function with argument (or without if commented out above)
commit_and_push "$repo_path"