gpt4 book ai didi

git - Visual Studio Code : automatic commit git

转载 作者:太空狗 更新时间:2023-10-29 14:35:21 24 4
gpt4 key购买 nike

很多时候,我忘记将我的编辑提交到我的 git。如果我关闭 VSCode,我就不能再使用 ctrl-Z。因为,我设置了 git,我想我可以使用类似每 30 秒左右自动提交的东西。

我看过这个extension btu ti 不是开源的,所以我不想使用它。我还找到了this但我的编程技能还不足以实现它。

我也想知道以这种方式使用 git 是否是一个不错的选择,因为 git 文件夹可能很快就会变得很重(我的 git 只是本地的,所以我可以处理几千兆)

那么实现我想做的事情的最好方法是什么?

最佳答案

2018 年:

I also wonder if using git in this way is a good option

不,那会污染你的提交历史。

使用扩展名“Local history”是更好的方法,并且不依赖于您的 VCS。
(并且是开源的:github.com/zabel-xyz/local-history)

Every time you modify a file, a copy of the old contents is kept in the local history.
At any time, you can compare a file with any older version from the history.
It can help you out when you change or delete a file by accident.
The history can also help you out when your workspace has a catastrophic problem.


2022:无需使用 VSCode 1.66(2022 年 3 月)进行扩展。
VSCode 现在包括:

Local history

Local history of files is now available from the Timeline view. Depending on the configured settings, every time you save an editor, a new entry is added to the list:

Local History

Each local history entry contains the full contents of the file at the time the entry was created and in certain cases can provide more semantic information (for example, indicate a refactoring).

From an entry you can:

  • Compare the changes to the local file or previous entry.
  • Restore the contents.
  • Delete or rename the entry.

There are new global commands to work with local history:

  • workbench.action.localHistory.create - Create a new history entry for the active file with a custom name.
  • workbench.action.localHistory.deleteAll - Delete all history entries across all files.
  • workbench.action.localHistory.restoreViaPicker - Find a history entry to restore across all files.

还有用于处理本地历史记录的新设置:

  • workbench.localHistory.enabled - Enable or disable local history (default: true).
  • workbench.localHistory.maxFileSize - File size limit when creating a local history entry (default: 256 KB).
  • workbench.localHistory.maxFileEntries - Local history entries limit per file (default: 50).
  • workbench.localHistory.exclude - Glob patterns for excluding certain files from local history.
  • workbench.localHistory.mergeWindow - Interval in seconds during which the last entry in local file history is replaced with the entry that is being added (default 10s).

A new filter action in the Timeline view toolbar allows you to enable or disable individual providers:

Timeline Filter

注意:根据您对 VS Code 的使用情况,本地历史条目存储在不同的位置。

  • When opening local files, the entries are persisted in the local user data folder and
  • when opening remote files, they will be stored on the remote user data folder.
  • When no file system is available (for example, in certain cases when using VS Code for Web), entries are stored into IndexedDB.

关于git - Visual Studio Code : automatic commit git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53956236/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com