import subprocess import sys def run_cmd(cmd): result = subprocess.run(cmd, shell=True, capture_output=True, text=True) if result.returncode != 0: print(f"Command failed: {cmd}\nError: {result.stderr}") sys.exit(1) else: print(result.stdout) def main(): if len(sys.argv) < 2: print("Usage: python git_push.py 'Commit message here'") sys.exit(1) commit_msg = sys.argv[1] # Add all changes (you can modify this to add specific files if you want) print("Adding all changes...") run_cmd("git add .") # Commit print(f"Committing with message: {commit_msg}") run_cmd(f'git commit -m "{commit_msg}"') # Push print("Pushing to origin main...") run_cmd("git push -u origin main") print("Done.") if __name__ == "__main__": main()