Created
January 9, 2020 21:48
-
-
Save dnagl/8930d1f86c631f34193796c5607d7c3a to your computer and use it in GitHub Desktop.
Git commit & push for multiple subfolder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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