Git批处理脚本


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

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

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

shell bash git windows

你们最讨厌了 10 years, 8 months ago

方法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

kqm141 answered 10 years, 8 months ago

Your Answer