如果使用bash和git修改文件,如何自动更新文件?

时间:2022-10-17 15:56:55

The scenario: User wants to keep a repository on a server, weather it be Github or just any server which has Git installed, with all his dotfiles which he can upload his changes to which he makes to his dotfiles on his local machine. And he wants it to be automated so that every Nth day a job starts to check if his local dotfiles have been modified and if so the modifications get committed and pushed up to the server which contains the dotfile repository. The user keeps a local git repository under a home folder called .dotfiles/ and symlinks his dotfiles to the files under .dotfiles/.

场景:用户希望在服务器上保存一个存储库,天气是Github,或者只是安装了Git的任何服务器,所有他的dotfiles都可以上传他对本地机器上的dotfiles所做的更改。并且他希望它是自动化的,以便每个第N天开始检查他的本地dotfiles是否已被修改,如果是,则修改将被提交并推送到包含dotfile存储库的服务器。用户将本地git存储库保存在名为.dotfiles /的主文件夹下,并将其dot文件符号链接到.dotfiles /下的文件。

Also, when the user sets up a new operating system he wants to fetch those same dotfiles from the server for his new OS.

此外,当用户设置新的操作系统时,他想从服务器获取相同的dotfiles以用于他的新操作系统。

The problem: User knows some bash programming, some general programming and some Git commands, but has no clue how to implement such a thing like this.

问题:用户知道一些bash编程,一些通用编程和一些Git命令,但不知道如何实现这样的事情。

The question: How does one create a thing like this?

问题是:如何创造这样的东西?

EDIT:

编辑:

Lets narrow this down.

让我们缩小范围。

How do I do automation in the shell. A job which happens every Nth day? I can handle the Git part an all that. I just need to know how to start a job automatically in the shell.

如何在shell中进行自动化。每个N天发生的工作?我可以处理Git部分。我只需要知道如何在shell中自动启动一个作业。

F.ex. job starts every Nth day to check for a given condition. I my case if the date of any of my dotfiles is newer than the date of the files in my local repo. If date is newer then the job runs a script which I write which handles the updating of everything. I know how to write the script for handling the updating of my files, I just don't know how to do this automation to check for the condition.

F.ex.每个N日开始工作以检查给定的条件。我是我的情况,如果我的任何dotfiles的日期比我本地仓库中的文件的日期更新。如果date更新,则作业运行我编写的脚本,该脚本处理所有内容的更新。我知道如何编写用于处理文件更新的脚本,我只是不知道如何进行自动化以检查条件。

How do you do the automation?

你是如何进行自动化的?

1 个解决方案

#1


1  

The problem: I want to do something I don't know how to do. The question: How do I do it?

问题:我想做一些我不知道该怎么做的事情。问题:我该怎么办?

I think you should look at cron (or incron) or something :)

我想你应该看看cron(或incron)或者什么:)

#1


1  

The problem: I want to do something I don't know how to do. The question: How do I do it?

问题:我想做一些我不知道该怎么做的事情。问题:我该怎么办?

I think you should look at cron (or incron) or something :)

我想你应该看看cron(或incron)或者什么:)