[关闭]
@yangfch3 2015-11-25T12:02:20.000000Z 字数 2060 阅读 6259

command line & git bash

windows


cmd

(windows可以shift+右键选择在当前目录打开命令行)

查看文本文件内容:

type [path\to\file]

查看两个文本文档的不同之处:

fc [path\to\file1] [path\to\file2]

命令行新建文件夹:

md [dirName]
mkdir [dirName]

命令行新建文件:

type NUL>[path\to\file]:在某个路径下新建文件
cd>[path\to\file]:在某个路径下新建文件
cd.>[path\to\file]:在某个路径下新建文件
> 用于把输出结果转向

删除文件:

del [path\to\file]
erase [path\to\file]
-----删除指定路径的文件
del [path\to\floder] del [path\to\floder\*]
-----删除某个目录下所有的文件
del /s [path\to\floder]
-----加上 /s 参数代表删除指定文件夹文档树里的所有文档,但是不删除文件夹,即不影响结构,但是目录下以及各级子目录下的具体的文档都会被删掉

删除文件夹:

rd [path\to\floder]
rmdir [path\to\floder]
-----只能删除空的文件夹
rd /s [path\to\floder]
rmdir /s [path\to\floder]
-----删除文件夹下所有文件及文件夹

目录跳转:cd可使用chdir

cd ../ cd ..\ :回到上一级
cd ..\..\ cd ../../ :回到上两级
cd / :回到根目录
cd [path\to\floder] :去到指定目录

显示文档树并输出为文本格式

tree [path/to/floder]>[path/to/file]
----- /f:加该参数能打印到文件级别(不加只能显示文件夹层级结构
dir [path/to/floder]>[path/to/file]
----- /s:显示指定目录和所有子目录中的文件

> 是用于输出结果的转向,可以将输出结果导入指定路径的文档内,文档不存在则会被新建。

所以我们可以使用任意输出为空的命令搭配>符号来创建新文件

调用批处理程序

call [path/to/bat_file]

将命令行运行结果输出到文本文档:

[command order]>[path/to/file]
> 用于把输出结果转向

参考资料:cmd速查手册

* 注意:windows 下的文件路径使用的是 \
Windows 的路径中表示文件层级为什么会用反斜杠,而 UNIX 系统都用斜杠 ?


git

bashlinux 下的命令行工具

查看文本内容

cat [path/to/file]

git(bash)下使用vim编辑文本文件

vim [file]
1. 默认为normal模式,按i进入insert模式,按esc回到normal模式
2. shift+;进入命令模式
3. wq! enter 保存并退出vim编辑模式;q!是不保存就退出;w!存盘
VIM入门
git bash 出现vim的时候怎么退出
rm de
查看两个文本的不同之处:
diff [path/to/file1] [path/to/file2]

创建文件夹:

mkdir [path/to/floder]

列出当前所在目录:

pwd

罗列文件夹内所有文件:

ls <[path/to/file]>
ls <[path/to/file]> -a(l)

创建新文件:

touch [path/to/file]
>[path/to/file]

删除文件

rm [path/to/file]

删除文件夹以及内部的所有文件

rm -rf [path/to/file]

其他有用但易忘的 git 命令

ssh-keygen -t rsa -C "youremail@example.com"ssh-key生成
git checkout -- [file]:撤销对某文件未提交的修改(包括删除和改写),回到版本库的最新稳定状态
git reset HEAD file:用于unstage add(撤销add


help

各个命令行工具进入帮助的方法:


cmd帮助:

help:返回命令简单介绍列表
help [command]:返回该command的详细介绍


bash帮助

help
[order] --help
help [order]


git bash 查看帮助:

git help:命令查看帮助列表
-----git help -a:查看所有git命令
-----git help -g:查看git各个概念的本地网页教程
-----git help git:打开本地git网页教程的首页
git help [order]:打开该命令的教程页面粗体文本

-h:参数进入命令帮助信息
git [order] -h:在shell里查看某个命令的帮助信息


npm帮助

help命令
npm help:返回所有命令简单介绍列表
npm help [command]:打开本地该[command]帮助页面(HTML)

命令的-h参数
npm [command] -h


node帮助

node -h:返回所有命令简单介绍列表

git 参考手册
linux 常用命令手册

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注