【问题标题】:Why do I need to use git-bash instead of cmd?为什么我需要使用 git-bash 而不是 cmd?
【发布时间】:2021-09-03 17:01:30
【问题描述】:

我在 cmd(命令提示符)中使用 git。但是当我在GitHub Learning Lab 上选择一门课程时,他们推荐 git bash for windows os。正如我所说,我正在使用 cmd,为什么我需要使用 git bash 而不是 cmd?当我迁移到 git bash 这个有什么好处吗?

【问题讨论】:

  • 因为bashcmd 灵活得多——而且这意味着像shell-scripts .sh 这样的东西可以在Linux、macOS 和Windows 之间进行少量更改来重复使用。当您使用 cmd 和 Windows 批处理文件 (.bat / .cmd) 时,您会发现自己经常遇到由 CMD 自身特性引起的问题(例如,执行类似“如果它们与此模式匹配,则将所有文件/文件夹移动到另一个文件夹”)。微软放弃了修复 CMD 的尝试,转而发明了 PowerShell。
  • @Dai 关于it's surprisingly difficult to do something like "move all files/folders to this other folder if they match this pattern" 可以扩展吗? cmd 语法:move a*b?cd.e target。我认为在 Bash 中,执行诸如“将所有扩展名为 a 的文件重命名为扩展名为 b”之类的操作非常困难。命令:ren *.a *.b。重击:for i in (*.a); do mv ... err,... hmm... oh heck let's download the third-party utility "rename" instead.
  • @k314159 你曾经尝试在 CMD 中使用 for 吗?还是findstrfind?这是一千件小事,使用起来很痛苦。

标签: git-bash


【解决方案1】:

您不需要使用 Git Bash。这只是传统的,因为 Git 是在 Linux 上开发和设计的,大多数 Git 用户使用 Linux,并且在 Windows 上使用 Git Bash 使其成为一种统一的体验。你当然可以在 cmd 上使用 Git;只需确保将C:\Program Files\git\cmd 添加到您的PATH

【讨论】:

    猜你喜欢
    • 2011-07-07
    • 2021-07-15
    • 1970-01-01
    • 1970-01-01
    • 2019-09-29
    • 1970-01-01
    • 2013-12-07
    • 2014-08-08
    • 2010-10-13
    相关资源
    最近更新 更多