search

Home  >  Q&A  >  body text

shell - Git批处理脚本

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

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

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

天蓬老师天蓬老师2798 days ago840

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-24 09:13:29

    Method 1:
    From here: http://mayecn.com/blog/2013/05/03/multiple-alias/

    First execute in git bash:
    alias blog='git add .;git commit -m "blog update"';git push origin gh-pages

    When you want to update your blog in the future, just do it directly blog


    Method 2:
    From here: http://stackoverflow.com/questions/7534184/git-alias-multiple-commands-and-parameters

    Execute in git bash
    git config --global alias.blog '!git add . && git commit -m "blog update" && git push origin gh-pages'

    or

    Edit the .gitconfig file and add this paragraph:

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

    When you want to update your blog in the future, execute git blog

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:13:29

    In fact, it is in the git installation directory. Create a git-xxx file and use shell to write that file. Then use

    git xxx
    

    It’s ready to run. .

    For example, if your requirement is to use git add, git commit, and git push continuously, you can add the "git-acp" file in that directory with the following content

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

    Then, in the directory that needs to be called, call

    git acp "Commit Message"
    

    That’s it. .

    Also, if you don’t use shell, but use python or other programming language, it is also possible. .

    reply
    0
  • 迷茫

    迷茫2017-04-24 09:13:29

    Sao Nian. Use TortoiseGit. Little turtle. Same as svn. https://code.google.com/p/tortoisegit/

    reply
    0
  • Cancelreply