Skip to content

Commit 5a0259b

Browse files
Add files via upload
1 parent 10dc1a9 commit 5a0259b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

clear-commits.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import subprocess
2+
3+
def run_command(command):
4+
"""Run a command in the shell and print the output."""
5+
try:
6+
result = subprocess.run(command, check=True, text=True, capture_output=True)
7+
print(result.stdout)
8+
except subprocess.CalledProcessError as e:
9+
print(f"Error: {e.stderr}")
10+
exit(1)
11+
12+
# Switch to a new orphan branch
13+
run_command(["git", "checkout", "--orphan", "new_branch"])
14+
15+
# Stage all changes
16+
run_command(["git", "add", "."])
17+
18+
# Commit changes
19+
run_command(["git", "commit", "-m", "new_commit"])
20+
21+
# Delete the old main branch
22+
run_command(["git", "branch", "-D", "main"])
23+
24+
# Rename the new branch to main
25+
run_command(["git", "branch", "-m", "main"])
26+
27+
# Force push to the remote main branch
28+
run_command(["git", "push", "-f", "origin", "main"])

0 commit comments

Comments
 (0)