git 常用操作 & yarn 命令 & vscode 快捷键

272 阅读1分钟

git 常用命令

查看提交信息

git log

git log --pretty=oneline // 美化格式展示一行信息

查看文件状态

git status

查看分支

git branch -a

git branch --all

查看文件差异

git diff

修改commit信息 <未提交到远程仓库时>

git commit --amend

合并commit信息

git rebase -i <commit id>

拉取远程分支

git pull origin <分支名>

撤销 git add 操作

git reset <file>

git restore --stage <file>

撤销工作区文件

git checkout <file>

撤销到指定的commit版本

git reset <commit id>

修改分支名

git branch -m <old-branch-name> <new-branch-name>

删除远程分支 2种方式

git branch --delete origin <branch-name> git branch origin :<branch-name>

推送到远程分支

git push origin <branch-name>

给指定的commit创建轻量标签

git tag <标签名> <commit-id> 例如: git tag tag_9.25 3ae39c574

创建带有附加信息标签 -a:理解为 annotated 的首字符,表示附注标签

git tag -a [标签名称] [提交版本号] -m [附注信息]

yarn的常用操作

配置镜像源 yarn config set registry https://registry.npm.taobao.org/

安装 yarn install // 如果想避免重新修改yarn.lock文件,可对比yarn.lock中镜像源,与本地的yarn config list中镜像源是否一致,不一致时会重新覆写yarn.lock

清理缓存 yarn cache clean

vscode 快捷键 mac

Command + F 当前文件查找 Command + Option + F 当前文件查找替换

Command + Shift + F 多文件查找 Command + / 单行注释 Shift + Option + A 多行注释 ``