首页 > Git批处理脚本

Git批处理脚本

弄了个静态博客,但是每次上传觉得挺麻烦的,git add .,git commit -m '',git push origin gh-pages什么的...麻烦死了...啊对了我是在Windows下..

所以我就想写成一个.bat的批处理脚本试试(blog的话commit log也不用天天写0_0)

结果写到调用Git bash之后就不知道怎么办了,对批处理不是很懂,所以在这里请教下大大们


其实,在git的安装目录下。建立一个git-xxx文件,用shell去写那个文件。然后使用

git xxx

就可以运行了。。

比如,你的需求是连续使用git add, git commit, git push, 可以在那个目录里,添加"git-acp"文件,内容如下

#!/bin/sh
git add .
git commit -am "$1" 
git push origin gh-pages

然后,在需要调用的目录里,调用

git acp "Commit Message"

就可以了。。

而且,如果你不用shell,而是用python或者其他编程语言,也是可以的。。


骚年。有TortoiseGit用啊。小乌龟啊。跟svn一样一样的。https://code.google.com/p/tortoisegit/


方法1:
来自这里: http://mayecn.com/blog/2013/05/03/multiple-alias/

先在 git bash 里执行:
alias blog='git add .;git commit -m "blog update"';git push origin gh-pages

以后要更新博客时,直接执行 blog


方法2:
来自这里: http://stackoverflow.com/questions/7534184/git-alias-multiple-commands-and-parameters

在 git bash 里执行
git config --global alias.blog '!git add . && git commit -m "blog update" && git push origin gh-pages'

或者

编辑 .gitconfig 文件,加上这么一段:

[alias]
    blog = !git add . && git commit -m 'blog update' && git push origin gh-pages

以后要更新博客时,执行 git blog

【热门文章】
【热门文章】