Skip to content

Instantly share code, notes, and snippets.

@dnagl
Created January 9, 2020 21:48
Show Gist options
  • Save dnagl/8930d1f86c631f34193796c5607d7c3a to your computer and use it in GitHub Desktop.
Save dnagl/8930d1f86c631f34193796c5607d7c3a to your computer and use it in GitHub Desktop.
Git commit & push for multiple subfolder
import os
import sys
def gitAddAll():
os.system("git add .")
def gitCommit():
os.system("git commit -m '" + commitmsg + "'")
def gitPush():
os.system("git push")
rootdir = os.getcwd()
ignoreDir = ["bin"]
if len(sys.argv) -1 == 0:
print("give me a commit!!")
exit(0)
commitmsg = sys.argv[1]
print("[*] Using commit: '" + commitmsg + "'")
for item in os.listdir(rootdir):
absolutePath = os.path.join(rootdir, item)
if os.path.isfile(absolutePath) or item in ignoreDir:
continue
print("[*] Current dir: " + absolutePath)
os.chdir(absolutePath)
gitAddAll()
gitCommit()
gitPush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment