使用UNIX环境下的bash脚本自动化提交仓库到github

博主分享了如何在Mac的UNIX环境下编写bash脚本来自动化提交代码到github,以提高工作效率。脚本最初缺少动态设置commit注释的功能,后续进行了优化,实现了根据用户输入自定义commit信息。
摘要由CSDN通过智能技术生成

我本人一直在写一些玩具代码的时候,有提交到github上备份的习惯,由于这个是我自己写的玩具代码,也不涉及到多个分支,所以每次都是机械的敲一串相同的命令,为了提高生产力,在Mac的UNIX环境下写一个bash脚本,自动化每次提交到github,我每次只需要执行这个脚本就行了,下面给出源码:

#!/bin/bash

echo "start git add commit fetch merge push"
echo "git add -A"
git add -A

echo "git commit -m 'leetcode-louyuting'"
git commit -m 'leetcode-louyuting'

echo "git fetch origin master"
git fetch origin master

echo "git merge origin/master"
git merge origin/master

echo "git push origin master:master"
git push origin master:master

这个脚本大大提交了我的生产效率。

改进

上面的脚本没法设置commit的注释,采用的统一的注释,所以后面优化了下,采用动态设置commit注释的方式脚本如下:

#!/bin/bash

echo "git add ."
git add .

echo "git commit"
echo "请输入commit的注释信息:"
comment="commit new code"
read comment
git commit -m "$comment"

echo "git fetch origin master"
git fetch origin master

echo "git merge origin/master"
git merge origin/master

echo "git push origin master:master"
git push origin master:master
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值