如何使“提交并推动"自动化.过程? (git) [英] how to automate the "commit-and-push" process? (git)

查看:61
本文介绍了如何使“提交并推动"自动化.过程? (git)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git repo.在代码库中进行的每个重大更改之后,我要做的就是去终端并执行一组命令.

I have a git repo. And after each major change, that I make in the codebase, what I do is that I go to the terminal and execute a set of commands.

git add .
git commit -m 'some message'
git push origin master

每天都是一样的,过程很无聊.谁能建议一种以某种方式使该过程自动化的方法?

These are the same each day and the process is quite boring. Can anyone suggest a way to somehow automate this process?

我正在运行Linux Mint 14操作系统.

I am running a Linux Mint 14 OS.

推荐答案

您可以使用Bash脚本非常轻松地自动执行此操作.

You can very easily automate this using Bash scripting.

git add .

echo 'Enter the commit message:'
read commitMessage

git commit -m "$commitMessage"

echo 'Enter the name of the branch:'
read branch

git push origin $branch

read

将以上代码存储为.sh文件(例如gitpush.sh)

store the above code as a .sh file(say gitpush.sh)

由于必须将此sh文件设为可执行文件,因此需要在终端中一次运行以下命令:

And since you have to make this sh file an executable you need to run the following command in the terminal once:

chmod +x gitpush.sh

现在运行此.sh文件.

每次运行它时,它将要求您提供提交消息和分支的名称.如果分支不存在或未定义推送目的地,则git将生成错误.要读取此错误,我添加了最后一个read语句.如果没有错误,则git生成pushed successfully类型的消息.

Each time you run it, It will ask you for the commit message and the name of the branch. In case the branch does not exist or the push destination is not defined then git will generate an error. TO read this error, I have added the last read statement. If there are no errors, then git generates the pushed successfully type-of message.

这篇关于如何使“提交并推动"自动化.过程? (git)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆