基本操作命令
who 查看当前系统有哪些使用者
history 列出所有历史命令
history 10 列出最近的10条历史命令
open . 使用Finder打开当前目录
sudo 使用特殊权限运行命令
ls 查看当前终端目录下面的文件
pwd 查看当前终端目录所在的位置
cd 进入用户主目录
cd xx 进入某个文件夹
cd ~ 进入用户主目录
cd - 返回进入此目录之前所在的目录
cd … 返回上一级目录
cd …/… 返回上两级目录
mkdir test 创建一个文件夹
touch test.txt 创建一个文件
cp 复制文件到另一个文件夹
cp test/test.txt test2/ 将test目录下面的test.txt复制到test2文件夹内
cp test/test.txt test2/text2.txt test3/ 复制多个文件到test3文件夹
cp test/t*.txt test2/ 复制test目录下面所有以t开头的txt文件
mv test/test.txt test2/ 和复制文件的的方法类似
rm test.txt 删除文件
rm -r test 删除test文件夹及其下的所有内容
echo “hello world” 输入内容
echo “hello world” > hello.txt 创建一个txt格式文本其内容为’hello world’
cat hello.txt 输出hello.txt文件中的内容
cat hello.txt > world.txt 将hello里面的内容覆盖掉world.txt里面,输出cat world.txt可查看
cat hello.txt >> world.txt 将hello里面内容追加到world.txt后面
git命令
git config --global user.name “你的名字” 配置Git用户名
git config --global user.email “你的邮箱” 配置Git邮箱
git log 查看日志
git reflog 查看提交记录
git reset --hard 版本回退(删除本地提交)
git branch -a 查看远程分支
git branch branchName 创建新分支
git checkout branchName 切换到新分支
git checkout -b branchName 上述两个命令的合并,创建并切换到该分支
git init 初始化本地仓库
git stash 这是将本地代码回滚值至上一次提交的时候,就是没有你新改的代码
git stash pop 取出贮藏的代码,实现和本地的代码合并
git pull 拉取服务器代码
git add -u 提交被修改(modified)和被删除(deleted)文件,不包括新文件(new)
git add . 提交新文件(new)和被修改(modified)文件,不包括被删除(deleted)文件
git commit 将暂缓区代码提交到master分支
git remote add origin git@gitlab.com:…(远程仓库地址) 给本地代码仓库和远程代码仓库添加关联 ,查看关联
git push -u origin master 第一次推送到远程仓库
git push origin master 将本地代码上传到远程代码仓库(非首次)
git tag -a ‘0.0.1’ -m ‘标签描述’ 给本地代码打个标签
git push —tags 将本地标签推送到远程代码仓库
git tag -d 0.0.1 / git push origin – delete tag 0.0.1 删除本地标签/删除远程标签
git status 查看代码状态,查看本地工作区是否有需要提交的内容
git clone xxx(项目仓库地址) 克隆仓库到本地