git常用命令整理:
- git clone "github.com/lilySMG/plu…" 克隆远程仓库代码
- git init 初始化本地版本库
- git status 查看当前工作目录被修改的文件
- git remote -v 列出配置过的远程分支
- git remote show
<remoteName>
展示远程仓库信息 - git remote add origin
<https>
跟远端仓库建立链接 - git branch -m
<oldName> <newName>
给本地分支重命名 - git checkout
<branchName>
迁出分支 - git branch -v 展示现有分支,*为当前分支
- git add . 所有文件放到暂存区
- git commit -m "嵌入注释" 嵌入代码
github远程仓库与本地建立链接:
1.登录github,新建Repositories
2.新建ignore和readMe相关文件
3.进入项目文件:git init-----git clone <httpsName>
-----git add .-----git commit -m "嵌入注释"-----git remote add origin <httpsName>
-----git pull-----git push origin <branchName>
常见错误整理:
1、git push 嵌入代码时提示没有匹配分支
解决方案:将本地分支名字改为远程分支名字 git branch -m
<oldName> <newName>
2、git push 嵌入代码时提示没有上游分支
解决方案:1、确认与远程仓库建立链接:git remote add origin <httpsName>
;2、把远程仓库和本地同步,消除差异
git pull origin <branchName>
--allow-unrelated-histories;3、重新add和commit文件;4、执行push命令:git push origin <branchName>
3、git push提示有冲突,不能合并
解决方案:1、vscode查看产生冲突文件,可用vscode手动解决冲突;也可用命令查看冲突的文件:git diff;2、合并冲突后执行命令嵌入代码:git commit -m "解决冲突";git push origin
<branchName>
npm发包流程:
- 进入项目文件npm init------npm adduser(设置npm登录用户)-----npm publish(如果npm的包地址设置了淘宝镜像,需要设置npm config set registry registry.npmjs.org)
- 更新包:npm version <版本号>-------npm publish
npm发包常见错误整理:
1.npm publish出现下图错误,将淘宝镜像地址改为npm config set registry registry.npmjs.org
补充知识:
window命令操作:cd 命令行打开切换文件夹操作