有没有办法避免GIT历史上多余的空间变化?

发布于 2025-01-17 22:21:56 字数 310 浏览 2 评论 0原文

如果一个人犯了一个小错误的格式化,例如缩进一条不需要缩进的行,是否有办法在提交历史上没有这个方法。

例如,我可以看到我可以看到的git diff ...

-  const getUniqueUserID = require('./websocket-user-id');
+const getUniqueUserID = require('./websocket-user-id');

在提交历史记录中看到这可能很烦人。这确实只是2个空间的变化,格式很难阅读。

我应该只使用另一个更实质性的修复来提交这个空间修复?

If one has made a minor mistake to formatting, say indenting a line that does not need to be indented, is there a way to not have this in the commit history.

For example using git diff I can see ...

-  const getUniqueUserID = require('./websocket-user-id');
+const getUniqueUserID = require('./websocket-user-id');

which might be annoying to see in the commit history. Is this indeed just a change of 2 spaces, the formatting is hard to read.

Should I just commit this space fix with another more substantial fix?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

救星 2025-01-24 22:21:56

您是否担心有额外的提交,或者您是否担心差异不太有用?

您可以使用 -b-w--ignore-space-change--ignore-all-space 来最小化差异,但是提交就是提交,如果这是历史的一部分,隐藏它会更令人困惑。

我倾向于认为,进行一个描述清楚的小更改并不是什么大问题,即使它只是空白。

Are you concerned about there being an extra commit, or are you concerned with the diff being less useful?

You can use -b and -w (--ignore-space-change and --ignore-all-space) to minimize the diff, but a commit is a commit and if it's a part of the history it would be more confusing to hide it.

I tend to think it's not a big deal to make a small well-described change, even if it's whitespace-only.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文