git add, commit and push commands in one?

前端 未结 30 1295
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 03:15

Is there any way to use these three commands in one?

git add .
git commit -a -m \"commit\" (do not need commit message either)
git push

Som

相关标签:
30条回答
  • 2020-12-02 04:08

    Since the question doesn't specify which shell, here's the eshell version based on the earlier answers. This goes in the eshell alias file, which might be in ~/.emacs.d/eshell/alias I've added the first part z https://github.com/rupa/z/ which let's you quickly cd to a directory, so that this can be run no matter what your current directory is.

    alias census z cens; git add .; git commit -m "fast"; git push
    
    0 讨论(0)
  • 2020-12-02 04:10

    This Result - Try this: Simple script one command for git add, git commit and git push

    Open your CMD on Windows and paste this answer

    git commit -m "your message" . && git push origin master

    This example my picture screenshot : https://i.stack.imgur.com/2IZDe.jpg

    0 讨论(0)
  • 2020-12-02 04:11

    You can use bash script , set alias to launch any command or group of commands

    git commit -am "your message" && git push 
    
    0 讨论(0)
  • 2020-12-02 04:11

    If you use VSCode, you can download this extension which will let you do it in one simple keyboard shortcut.

    0 讨论(0)
  • 2020-12-02 04:12

    If the file is already being tracked then you do not need to run git add, you can simply write git commit -am 'your message'

    If you do not want to write a commit message you might consider doing something like

    git commit --allow-empty-message -am ''

    0 讨论(0)
  • 2020-12-02 04:14

    Set as an alias in bash:

    $ alias lazygit="git add .; git commit -a -m '...'; git push;";
    

    Call it:

    $ lazygit
    

    (To make this alias permanent, you'd have to include it in your .bashrc or .bash_profile)

    0 讨论(0)
提交回复
热议问题