github中的commit_editmsg中的评论是什么 [英] What is a comment in commit_editmsg in github

查看:380
本文介绍了github中的commit_editmsg中的评论是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了很长时间阅读并试图弄清楚git commit --amend,但是我仍然不明白#在editmsg中是如何使用的.

I have spent a long time reading and trying to figure out git commit --amend, but I still do not understand how the # are used in the editmsg.

我担心在不知道自己在做什么的情况下进行编辑,因为我已经阅读了git commit --amend仅执行最新的提交,并且一旦保存并退出,它将被视为新的提交.

I am worried to edit this without knowing what I am doing because I have read that git commit --amend only does the most recent commit,and once I save and exit , it will be counted as a new commit.

我不小心提交并推送了一些大文件(但推送失败).但是我还写了一些脚本,这些脚本应该从与大文件相同的提交中推送.

I have accidentally committed and pushed (but the push failed) some large files. But I have also written scripts that were supposed to be pushed from the same commit as the large files.

我正在尝试在新提交中删除包含大文件的行,但是我不知道如何执行此操作.

I am trying to delete the lines with the large files in the new commit , but I don't understand how to do this.

这是我下面的提交文件,但是如果我应该删除带有#的行,我就不会感到困惑(我尝试过此操作,但是它没有用,并且git日志是相同的):

This is my commit file below, but I don't understadn if I should delete the lines with the # (I tried this but it didn't work , and the git log is the same ):

the commit message of the one I want to change is here but I don't want to just change the message, I want to delete the large files in the commit so that the push works.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date:      Thu Feb 8 18:30:32 2018 -0900
#
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes to be committed:
#   new file:   script.py
#   new file:   super_large_file.npy <--- I deleted this line but it appeared again, it is becuase deleting a line with # is ignored?  Do I just rewrite the stuff after the # lines? 

我的问题是,为什么删除大文件的行(包括#)不起作用,并且提交仍然仍然要推送大文件?

My question is , why does deleting the line of the large file (including the # ) not work and the commit remains still wanting to push the large file?

我应该不使用#重写提交文件吗?但是我也读到git带走了#号,所以我很困惑

Should I just rewrite the commit file without the # ? But I also read that git takes away the # , so I am confused

推荐答案

首先,这些是注释:删除以#开头的行对git存储库内容无效.
它们包括提示和提交中包含的文件列表.

First, those are comments: removing a line starting with # has no effect in your git repository content.
They include hints and the list of files included with the commit.

为了真正从您的回购记录中删除该文件,我建议您使用新的替换BFG和git filter-branch .

I would recommend, in order to actually remove that file from your repo history, to use the new git filter-repo which replaces BFG and git filter-branch.

注意:如果在运行上述命令时收到以下错误消息:

Note: if you get the following error message when running the above-mentioned commands:

Error: need a version of `git` whose `diff-tree` command has the `--combined-all-paths` option`

这意味着您必须更新git .

it means you have to update git.

首先:执行一份本地存储库副本(一个新克隆)

First: do that one copy of your local repo (a new clone)

请参阅"

git filter-repo --path file-to-remove --invert-paths

最后,您可以(如果您是该存储库中唯一的工作人员)进行git push --force

At the end, you can (if you are the only one working on that repository) do a git push --force

第二,在提交消息中显示的提示随着Git 2.25.1(2020年2月)的变化而变化:当没有要提交的内容但不遵守时,"git commit"给出的输出类似于"git status". advise.statusHints配置变量 ,该问题已得到纠正.
参见讨论.

Second, the hints displayed in a commit messages are changing with with Git 2.25.1 (Feb. 2020): "git commit" gives output similar to "git status" when there is nothing to commit, but without honoring the advise.statusHints configuration variable, which has been corrected.
See discussion.

请参见提交5c4f55f (2019年12月17日)由 Junio C Hamano-gitster-

See commit 5c4f55f (17 Dec 2019) by Heba Waly (HebaWaly).
(Merged by Junio C Hamano -- gitster -- in commit 9403e5d, 22 Jan 2020)

commit :拒绝空提交时应尊重advice.statusHints

签名人:Heba Waly

commit: honor advice.statusHints when rejecting an empty commit

Signed-off-by: Heba Waly

ea9882bfc4 (提交:在写入COMMIT_EDITMSG, 2013时禁用状态提示-09-12)目的是在写入COMMIT_EDITMSG,时禁用状态提示,因为在"git status"中给出提示(如提交消息模板中的输出)为时已晚而无用(他们说'git add"之类的东西'to stage",但这只有在中止当前的"git commit"会话之后才有可能.

In ea9882bfc4 (commit: disable status hints when writing to COMMIT_EDITMSG, 2013-09-12) the intent was to disable status hints when writing to COMMIT_EDITMSG, because giving the hints in the "git status" like output in the commit message template are too late to be useful (they say things like "'git add' to stage", but that is only possible after aborting the current "git commit" session).

但是在一种情况下,提示可能很有用:由于索引中未记录任何更改而导致当前的提交尝试被拒绝.

给出了消息,并显示了"git commit"错误,因此用户可以立即遵循提示.

The message is given and "git commit" errors out, so the hints can immediately be followed by the user.

教导代码路径以遵循配置变量.

Teach the codepath to honor the configuration variable.

提示(现在在提交消息编辑器中可见)将是:

The hint (now visible in the commit message editor) will be:

no changes added to commit (use "git add" and/or "git commit -a")

这篇关于github中的commit_editmsg中的评论是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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