import os import time import subprocess # Function to update .gitignore file def update_gitignore(): with open(".gitignore", "w") as gitignore_file: gitignore_file.write("gitsaves.py\n") # Function to perform git commit and push def git_commit_and_push(): current_time = time.strftime("%Y-%m-%d %H:%M:%S") commit_message = f"{current_time} Autosave for checkpoint additions" print("Pushing with commit `"+commit_message+"`") subprocess.run(["git", "add", "."]) subprocess.run(["git", "commit", "-m", commit_message]) subprocess.run(["git", "push"]) # Main loop if __name__ == "__main__": try: while True: update_gitignore() git_commit_and_push() print(f"Autosaved at {time.strftime('%H:%M:%S')}") time.sleep(600) # Sleep for 10 minutes (600 seconds) except KeyboardInterrupt: print("Autosave stopped.")