-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_script.sh
More file actions
executable file
·42 lines (29 loc) · 1.25 KB
/
commit_script.sh
File metadata and controls
executable file
·42 lines (29 loc) · 1.25 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
#!/bin/bash
# Repository directory (update this with your actual repo path)
repo="/Users/tharushikawodya/Developer/new"
# Navigate to the repository
cd $repo || { echo "Repository path not found"; exit 1; }
# File to modify (ensure this file exists in your repository)
file_to_modify="dummy_file.txt"
# Number of commits
total_commits=12
# Start date (ensure this is a recent date within this year)
start_date="2024-04-19 07:00:00"
# Custom commit message prefix
commit_message="Progress update"
# Create the specified number of commits
for i in $(seq 1 $total_commits)
do
# Increment the commit date by hours to spread them out
commit_date=$(date -j -v+${i}H -f "%Y-%m-%d %H:%M:%S" "$start_date" +"%Y-%m-%d %H:%M:%S")
# Make a small change to the file
echo "Progress update number $i on $commit_date" >> $file_to_modify
# Stage the file
git add $file_to_modify
# Create a commit with the calculated date and custom message
GIT_COMMITTER_DATE="$commit_date" GIT_AUTHOR_DATE="$commit_date" git commit -m "$commit_message - Commit number $i"
# Print the commit number and date for verification
echo "Created commit number $i with date $commit_date"
done
# Push all commits to the default branch (e.g., 'main')
git push origin main