在使用 Git 時,最常用的莫過於 add -> commit -> push 三步操作了。但是對於懶惰的程序員來說,一遍遍地敲簡直就是災難!
除了按 ↑ 方向鍵,有沒有辦法實現一鍵三連? 😎
噔噔!寫個腳本 git-push.sh,如下:
#!/bin/bash
echo "Enter your message"
read message
git add .
git commit -m"${message}"
if [ -n "$(git status - porcelain)" ];
then
echo "IT IS CLEAN"
else
git status
echo "Pushing data to remote server!!!"
git push -u origin master
fi
增加執行權限:
chmod +x git-push.sh
爲方便使用,把它放到系統路徑下:
sudo cp git-push.sh /usr/local/bin/
趕緊試一下吧
LetsGit$ git-push.sh
Enter your message
記得 點贊、投幣、收藏!