【发布时间】:2021-09-03 17:01:30
【问题描述】:
我在 cmd(命令提示符)中使用 git。但是当我在GitHub Learning Lab 上选择一门课程时,他们推荐 git bash for windows os。正如我所说,我正在使用 cmd,为什么我需要使用 git bash 而不是 cmd?当我迁移到 git bash 这个有什么好处吗?
【问题讨论】:
-
因为
bash比cmd灵活得多——而且这意味着像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吗?还是findstr与find?这是一千件小事,使用起来很痛苦。
标签: git-bash