generated from CursedPrograms/project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b7db36
commit 3897ea6
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import subprocess | ||
|
||
def run_command(command): | ||
"""Run a command in the shell and print the output.""" | ||
try: | ||
result = subprocess.run(command, check=True, text=True, capture_output=True) | ||
print(result.stdout) | ||
except subprocess.CalledProcessError as e: | ||
print(f"Error: {e.stderr}") | ||
exit(1) | ||
|
||
# Switch to a new orphan branch | ||
run_command(["git", "checkout", "--orphan", "new_branch"]) | ||
|
||
# Stage all changes | ||
run_command(["git", "add", "."]) | ||
|
||
# Commit changes | ||
run_command(["git", "commit", "-m", "new_commit"]) | ||
|
||
# Delete the old main branch | ||
run_command(["git", "branch", "-D", "main"]) | ||
|
||
# Rename the new branch to main | ||
run_command(["git", "branch", "-m", "main"]) | ||
|
||
# Force push to the remote main branch | ||
run_command(["git", "push", "-f", "origin", "main"]) |