git 恢复git跟踪
Hi, folks, let me share my experience of creating an application to keep track of my spendings. Specifically, let me do it by answering the following questions:
嗨,人们,让我分享我创建应用程序的经验,以跟踪我的支出。 具体来说,让我通过回答以下问题来做到这一点:
- Why keep track of spendings in an application? 为什么要跟踪应用程序中的支出?
- Why did I create the application as a personal project? 为什么将应用程序创建为个人项目?
- Why does the project use Git+JS? 为什么项目使用Git + JS?
1. Why keep track of spendings in an application?
1.为什么要跟踪应用程序中的支出?
I, like many people out there, wanted to become rich and successful. To become rich, one is often advised to run a personal budget, that's what I started to do several years ago. I'd like to point out that running my personal budget hasn't made me rich and successful, and I increased income simply by moving to Moscow.
我和那里的许多人一样,希望变得富有和成功 。 为了致富,经常有人建议自己做一个个人预算,这就是我几年前开始做的事情。 我想指出的是,花我的个人预算并没有使我变得富有和成功,我只是搬到莫斯科来增加收入。
I think I started to run the budget somewhere around 2012. By that time I already had a professional programmer deformation, which can be described as "made by someone else = bad" formula and is usually manifested by a strong desire to rewrite everything from scratch. However, I had no experience with budgeting back then, so I decided to try a "professional" solution and purchased YNAB (You Need A Budget) to use the application on both PC and mobile.
我想我是在2012年左右开始预算的。那时我已经经历了专业的程序员变形,可以形容为“别人造的=坏”的公式,通常表现为强烈的从头开始重写所有内容的愿望。 。 但是,那时我还没有预算方面的经验,因此我决定尝试一种“专业”解决方案,并购买了YNAB (您需要预算)在PC和移动设备上使用该应用程序。
I tried to do my best to set out budget plans and fulfill them in the course of three years. However, somewhere around 2015 the authors released a new application version and demanded money for the upgrade, the old version was no longer functioning. I had to choose one of the options:
我尽力制定预算计划并在三年的时间内实现这些计划。 但是,在2015年左右某个时间,作者发布了新的应用程序版本,并要求付费进行升级 ,旧版本不再起作用。 我必须选择以下选项之一:
- Pay for the upgraded version and use a completely new "shiny" user interface. 支付升级版本的费用,并使用全新的“发光”用户界面。
- Stop their ripoff, keep my money and lose the history of spendings. 停止抢劫,保留我的钱,失去支出的历史。
I concluded that:
我得出的结论是:
- I already paid for the application; 我已经为申请付款了;
- the old version was suitable for me; 旧版本适合我;
- I did not ask for an upgrade; 我没有要求升级;
- if I would know I have to pay for each upgrade, I would have never purchased their application in the first place; 如果我知道我必须为每次升级付费,那么我永远不会一开始就购买他们的应用程序;
- I didn't want to sponsor this boorishness; 我不想赞助这种无聊。
so I stopped the ripoff and lost my history of spendings.
因此我停止了盗窃,并失去了消费经历 。
This was a very disappointing situation for me, so I stopped tracking my spendings for about a year. However, I was once experiencing a "painful synchronization" (also known as "figuring things out" with a wife). I failed to defend myself against a financial vocal attack like "you're a waster, you always waste money on junk". Then I realized I really need to keep track of my spendings.
这对我来说是一个非常令人失望的情况,所以我停止跟踪支出大约一年了。 但是,我曾经经历过“痛苦的同步”(也称为与妻子“弄清事情”)。 我没有为自己辩护,以免遭受诸如“您是一个浪费者,您总是把钱浪费在垃圾上”之类的财务声音攻击。 然后我意识到我真的需要跟踪自己的支出。
This time I decided not to repeat my mistake of giving all my data to someone with the risk of losing it, so I started to track my spendings with simple phone notes. The format was simple and looked like this:
这次我决定不再重复将所有数据提供给可能会丢失的人的错误,因此我开始使用简单的电话记录来跟踪我的支出。 格式很简单,看起来像这样:
![笔记](https://i-blog.csdnimg.cn/blog_migrate/45570714039c124d834f3c6e32d38610.png)
I used the notes solely on the phone until mid-2018. Then, a new need arose: I wanted to be able to work on my spendings from a PC to analyze them. I took the time to see through the solutions that would allow me to work with my spendings on both PC and mobile free of charge. A calendar turned out to be such a solution:
直到2018年中,我只在手机上使用笔记。 然后,出现了新的需求:我希望能够通过PC处理我的支出以进行分析。 我花了时间看通解决方案,这些解决方案使我可以免费使用PC和移动设备上的支出。 日历证明是这样的解决方案:
![日历](https://i-blog.csdnimg.cn/blog_migrate/6871f89d28e5781ef86e527dd817c63c.png)
![新纪录](https://i-blog.csdnimg.cn/blog_migrate/b1fe175696c9462f3dce814089c515c6.png)
I used a Google account to access Apps Script (a clone of JavaScript) to analyze the spendings. Working with spendings in Apps Script turned out to be quite daunting because calendar records are not designed to host spendings. Data ownership question was still unresolved: my data was still dusting on an unknown server I don't control, and I could only access my data through an API, which might change in the future by someone else's decision.
我使用一个Google帐户访问Apps Script (JavaScript的一个克隆)来分析支出。 事实证明,在Apps Script中处理支出非常艰巨,因为日历记录并非旨在托管支出。 数据所有权问题仍未解决:我的数据仍在我无法控制的未知服务器上传输,我只能通过API访问我的数据, 将来可能会因其他人的决定而改变 。
While I was using a calendar, I've had the following ideas frequently visiting me:
当我使用日历时,我经常有以下想法:
- it would be nice to keep all my data in Git to be able to easily analyze the spendings; 最好将我的所有数据保存在Git中,以便能够轻松分析支出;
- it would be nice to have a convenient user interface without all the noise that prevents me from quickly adding a record. 拥有一个方便的用户界面而没有所有妨碍我快速添加记录的杂音,将是很好的。
Autumn 2019 I discovered Isomorphic-Git, which allows JavaScript to work with Git, quickly verified the ability to work with Git, and realized I found my Holy Grail. Recently I've finished creating the first version of GitBudget application, you can see its functionality in the video at the beginning of the article.
2019年秋天,我发现了Isomorphic-Git ,它允许JavaScript与Git一起使用,Swift验证了与Git一起使用的能力,并意识到我找到了我的圣杯。 最近,我已经完成了GitBudget应用程序的第一个版本的创建,您可以在本文开头的视频中看到其功能。
That's how the spendings look like on my phone now:
这就是现在我手机上的支出情况:
![ГитБюджет](https://i-blog.csdnimg.cn/blog_migrate/3ccbc5bc41f07b648015cd96f9b4148e.png)
Git data looks like this: https://gitlab.com/kornerr/git-budget-sample-data/-/blob/me/gb.log
Git数据如下所示: https : //gitlab.com/kornerr/git-budget-sample-data/-/blob/me/gb.log
Let me highlight a few important issues:
让我强调一些重要的问题:
- Git repository above reflects actions performed in the video; 上面的Git存储库反映了视频中执行的操作;
- I keep my spendings in a private repository, you should do the same; 我将支出保存在私有存储库中,您也应该这样做;
- the application runs completely on the device and has no back-end: GitHub Pages hosting is used; 该应用程序完全在设备上运行,并且没有后端:使用GitHub Pages托管;
- the application talks to the outside world only during synchronization with Git; 该应用程序仅在与Git同步时才与外界对话;
- password is kept by a browser, the application only uses it for synchronization with Git; 密码由浏览器保存,应用程序仅将其用于与Git同步;
- the application should be loaded over HTTP because the currently used Isomorphic-Git version (0.70.0) makes some requests (metadata) to Git over HTTP, and browsers prohibit HTTP requests from HTTPS nowadays. 该应用程序应该通过HTTP加载,因为当前使用的Isomorphic-Git版本(0.70.0)通过HTTP向Git发出了一些请求(元数据),并且浏览器如今禁止HTTPS发出HTTP请求。
2. Why did I create the application as a personal project?
2.为什么将应用程序创建为个人项目?
I spent 40 hours of my life during the first quarter of 2020, i.e., on average, I worked for about half an hour each day.
我在2020年第一季度度过了40个小时的生命,即平均每天工作约半小时。
Personal projects have the following benefits over those done at work:
个人项目比工作中的项目具有以下好处:
- You can do whatever you want and learn from your mistakes. 您可以做任何想做的事情,并从错误中学习。
- Nobody's breathing down your neck and restricting your fantasy. 没有人会呼吸你的脖子,限制你的幻想。
- The above two points keep you calm and give you the strength to perform any stupid activity that might be required at work. 以上两点使您保持镇定,并有力量进行工作中可能需要的任何愚蠢的活动。
- Mistakes you own drastically widen your horizons. 你自己的错误极大地扩大了你的视野。
Personal projects have drawbacks, too:
个人项目也有缺点:
- Nobody in the world cares about your project but you. 除了您,世界上没有人关心您的项目。
- Nobody would pay you for your project. 没有人会为您的项目付钱。
- You have to find time to do the project every day. 您必须每天抽出时间来完成该项目。
- Your wife won't thank you for the project, even if she would use it herself. 即使您自己使用它,您的妻子也不会感谢您的项目。
It's easy to note that all drawbacks of the personal project are balanced with the benefits of the work project. And all drawbacks of the work project are balanced with the benefits of the personal project. Yin and Yang.
很容易注意到,个人项目的所有弊端都与工作项目的收益相平衡。 工作项目的所有弊端与个人项目的优点是平衡的。 阴阳。
3. Why does the project use Git+JS?
3.为什么项目使用Git + JS?
Keeping data in Git instead of an unknown back-end/API has the following benefits:
将数据保存在Git中而不是未知的后端/ API具有以下好处:
- Git is the most widespread solution for decentralized source version control among developers, i.e., almost every developer has experience with Git. Git是开发人员中用于分散源代码版本控制的最广泛的解决方案,即几乎每个开发人员都具有Git的经验。
- You don't need a new API to work with Git: you just work with files. 您不需要新的API即可使用Git:您只需使用文件即可。
- There are numerous services offering Git free of charge if you're not too crazy about security and don't want to pay for the service. 如果您不太担心安全性并且不想为该服务付费,则有许多免费提供Git的服务。
Of course, a Git service provider might be acquired by a large corporation one day, however, it's easy to move your Git data wherever you want.
- For maximum security you can always host your own Git server. 为了获得最大的安全性,您始终可以托管自己的Git服务器。
Usage of JS with HTML/CSS over Swift/Kotlin/C#/Python has the following benefits:
通过Swift / Kotlin / C#/ Python将JS与HTML / CSS结合使用具有以下好处:
- Your application runs everywhere: PC, tablet, mobile phone. 您的应用程序无处不在:PC,平板电脑,手机。
- You don't need to pass AppStore reviews to get to every device. 您无需通过AppStore评论即可访问所有设备。
HTML/CSS/JS standards are international, so no single company may stop supporting it or change its API; this may result in backward compatibility of 20 years or more.
HTML / CSS / JS标准是国际性的,因此没有任何一家公司可以停止对其进行支持或更改其API ; 这可能会导致20年或更长时间的向后兼容性。
Since there's no back-end, all logic resides in JS executed on the client, so you can save the version of the application that best suits you and forget about recurrent updates that usually only hamper usability.
由于没有后端,所有逻辑都驻留在客户端上执行的JS中,因此您可以保存最适合您的应用程序版本,而不必考虑通常只会妨碍可用性的经常性更新。
GitBudget is the first attempt to see what Git+JS can do. I can only imagine the possibilities lying ahead.
GitBudget是了解Git + JS可以做什么的第一次尝试。 我只能想象未来的可能性。
git 恢复git跟踪