- Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathcommit.py
More file actions
Latest commit
23 lines (16 loc) · 793 Bytes
/
Copy pathcommit.py
File metadata and controls
23 lines (16 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# https://www.steadylearner.com/blog/read/How-to-automatically-commit-files-to-GitHub-with-Python
importsubprocessascmd
cp=cmd.run("git add .", check=True, shell=True)
response=input("Do you want to use the default message for this commit?([y]/n)\n")
default="Edit README.md"
ifresponse.startswith('n'):
message=input("What message you want?\n")
# Use deafult_message when user mistakenly use enter here.
# When your intention is to automate, it will be no problem with reset_commit.py
# Use while with input prompt if you want to complicate this.
ifnotmessage:
message=default
else:
message=default
cp=cmd.run(f"git commit -m '{message}'", check=True, shell=True)
cp=cmd.run("git push -u origin master -f", check=True, shell=True)