让git自动提交 [英] Making git auto-commit

查看:208
本文介绍了让git自动提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用git来记录文件的所有更改。

有没有办法让git'commit'在每次文件更新时自动发生 - 所以每次文件更改都会有一个新的提交?

理想情况下,我希望我的用户甚至不知道git是在幕后运行的。然后,用户可能会撤销文件的更改 - 这可以通过将旧版本从git中提取出来。

p>在Linux上,您可以使用 inotifywait 在每次更改文件内容时自动执行命令。

编辑:以下命令提交文件.txt只要保存即可:

  inotifywait -q -m -e CLOSE_WRITE --format =git commit -m '自动提交更改'%wfile.txt | sh 


I'd like to use git to record all the changes to a file.

Is there a way I can turn git 'commit' on to automatically happen every time a file is updated - so there is a new commit for every change to a file?

Ideally I'd like my users to not even know that git is running behind the scenes. A user could then potentially "undo" changes to a file - and this could be achieved by pulling a previous version out of git.

解决方案

On Linux you could use inotifywait to automatically execute a command every time a file's content is changed.

Edit: the following command commits file.txt as soon as it is saved:

inotifywait -q -m -e CLOSE_WRITE --format="git commit -m 'autocommit on change' %w" file.txt | sh

这篇关于让git自动提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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