Git commit bash script

后端 未结 6 2140
刺人心
刺人心 2020-12-25 10:53

I\'m writing a bash script to add, commit, push all files in a directory.

#!/bin/bash  
git add .  
read -p \"Commit description: \" desc  
git commit -m $de         


        
6条回答
  •  天命终不由人
    2020-12-25 11:25

    it is helpful to remove from the index the files that have actually been deleted. git add -u takes care of this. Also, you may want to consider chaining these commands together like this:

    git add . && \
    git add -u && \
    git commit -m "$(read -p 'Commit description: ')" && \
    git push origin HEAD
    

    If any command fails, it will stop evaluating the remaining commands.

    Just food for thought (untested food).

    Thanks!

提交回复
热议问题