I have three .py files saved in the python shell/IDLE. I would like to commit and push them to my GitHub account/repo. Is this possible? and if so how?
To push changes from the current branch press Ctrl+Shift+K or choose Git | Push from the main menu. To push changes from any local branch that has a remote, select this branch in the Branches popup and choose Push from the list of actions.
To do it from macOS (Mac terminal) using the shell from python, you can do this:
#Import dependencies
from subprocess import call
#Commit Message
commit_message = "Adding sample files"
#Stage the file
call('git add .', shell = True)
# Add your commit
call('git commit -m "'+ commit_message +'"', shell = True)
#Push the new or update files
call('git push origin master', shell = True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With