无法自动填充 VS Code Git 源代码控制框的当前日期和时间。

huangapple go评论65阅读模式
英文:

Cannot autofill VS code Git source control box with current date and time

问题

问题: 我在GitHub上有一些个人的博士项目,只有我自己使用(即没有拉取/分支),我一直试图创建一个键盘绑定(或通过任何方式),可以自动填写当前日期和时间。这看起来比我目前的方法更专业,目前我只是使用 t 或其他键来看看仓库在哪个时间更新,而不需要查看历史记录。请问是否可以创建一个能够实现这一功能的按键:

我已经尝试过的: 我找到了@ianyongli对如何在vscode中插入当前日期时间?的回答,并进行了一些修改,如下所示:

{
    "key": "ctrl+.",
    "command": "git.commit",
    "args": {
        "snippet": "$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND"
    }
}

然而,这会弹出“请提供Git消息”并且不起作用(因为它自然而然地只是提交)。git.commit 没有进一步的选项,git. 本身有很多我不理解的选项,比如 git.commitMessageAccept,这个也不起作用。链接的回答在文本中有效,我可以复制粘贴到文本框中,但我不介意有一种自动的方式。

请问我漏掉了什么?

如果它同时提交并推送,那将很好,但不是必需的,正如我之前提到的,这并不是为了专业目的。我熟悉编程,但不熟悉VS Code的内部细节。我在这个网站上搜索有关在消息框中插入文本的问题,但甚至找不到内部称为什么的消息框,所以才提出了这个问题。

英文:

Problem: I have personal PhD projects on GitHub that are solely for me (i.e. no pull/branches) and I have been trying to create a keyboard binding (or via any means) that can autofill the current date and time. It would look more professional then my current method of just using t or whatever key so I can see when browsing the repository when things were updated without consulting the history. I would like a key that could do this please:

无法自动填充 VS Code Git 源代码控制框的当前日期和时间。

What I have tried: I have found an answer by @ianyongli to How to insert current date time in vscode? that I have adapted like so:

{
    "key": "ctrl+.",
    "command": "git.commit",
    "args": {
        "snippet": "$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND"
    }
},

However, this brings up the "please provide a message for Git" and does not work (as it naturally just commits). git.commit had no further options and git. itself had many options I did not understand like git.commitMessageAccept which does not work. The linked answer works in text and I can copy and paste it into the box but wouldn't mind an automatic way.

What am I missing please?

It would be nice but not essential if it committed and pushed at the same time, like I mentioned earlier this is not for professional purposes. I am familiar with programming but not VS code intricacies. I searched on this site for questions concerning inserting text into that message box but couldn't even find what the message box is called internally hence this question.

答案1

得分: 1

为什么要在提交信息中添加日期,它已经是提交的一部分。

使用别名修改您的日志语句:显示日期,以单行版本和引用名称(分支)。

git config --global alias.logd 'log --pretty=tformat:"%C(auto)%ci %h%d %s"'

要使用它,请在终端上输入以下命令:

git logd

英文:

why add the date to the commit message, it is already part of the commit.

modify your log statement with an alias: show the date, in a one line version and the ref names (branches)

git config --global alias.logd 'log --pretty=tformat:"%C(auto)%ci %h%d %s"'

to use it give the command on the terminal

git logd

huangapple
  • 本文由 发表于 2023年5月7日 05:51:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76191321.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定