单个项目内.git目录下创建run.vbs,你可以将vbs文件复制到任意一个项目的.git目录下且运行成功。
' 基本思路:在vbs当前目录Set objShell 打开命令窗口,输入git add .等命令,
' 输入本次更新内容,(git默认不显示运行窗口“,0,”,且等待命令执行成功“True”.
单个项目 .git目录下创建run.vbs实现
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run "git add .", 0, True
commitMessage = InputBox("commit message:", "Commit Message")
objShell.Run "git commit -m """ & commitMessage & """", 0, True
' objShell.Run "git pull origin master --allow-unrelated-histories", 0, True
' 执行git push命令
objShell.Run "git push", 0, True
Set objShell = Nothing
' 这样,脚本将使用当前脚本所在的目录作为本地Git仓库的目录。
多个项目,vbs文件位置随意, 加了一个For循环语句。
Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
' 设置本地项目目录列表
Dim projectDirectories(2)
projectDirectories(0) = "C:\path\to\project1"
projectDirectories(1) = "C:\path\to\project2"
projectDirectories(2) = "C:\path\to\project3"
For Each projectDirectory In projectDirectories
objShell.Run "git add .", 0, True
commitMessage = InputBox("commit message:", "Commit Message")
objShell.Run "git commit -m """ & commitMessage & """", 0, True
objShell.Run "git pull origin master --allow-unrelated-histories", 0, True
objShell.Run "git push", 0, True
Next
' 释放对象
Set objShell = Nothing
简单的鼠标能点一下就不点两下,最有用的代码也是最浪费时间的代码。
个人使用记录案例1
GitHub云盘化保存文件的一般化操作之vbs输入git命令。