git常见操作和常见错误

在当我们输入git remote add origin https://gitee.com/(github/码云账号)/(github/码云项目名).git
就会报如下的错
fatal: remote origin already exists.

git remote -v

在这里插入图片描述

 git remote rm origin(删除关联的origin的远程库)

在这里插入图片描述

如果输入$ git remote rm origin 还是报错的话,error: Could not remove config 
section 'remote.origin'. 我们需要修改gitconfig文件的内容
找到你的github的安装路径,我的是
C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fc
d3358bd96720bb5c8\etc
找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!
git remote add origin https://gitee.com/siguohui/srs5.git
git push -u origin "develop"

在这里插入图片描述

Git 全局设置:

git config --global user.name "8857807"
git config --global user.email "8857807@163.com"
创建 git 仓库:

mkdir srs5
cd srs5
git init 
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/siguohui/srs5.git
git push -u origin "master"
已有仓库?

cd existing_git_repo
git remote add origin https://gitee.com/siguohui/srs5.git
git push -u origin "master"
运行npm install报错解决方法
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/sohee-lee7/Squire.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! D:\node\node_cache_logs\2020-09-01T01_09_19_309Z-debug.log

解决办法
win + r 然后在弹出框中出入cdm,弹出如下界面,输入git,回车。
如果没git环境变量,需要安装git并添加环境变量
报错
npm ERR! Error while executing:
npm ERR! D:\soft\git\Git\bin\git.EXE ls-remote -h -t https://github.com/ElementUI/theme-default.git
npm ERR!
npm ERR! fatal: unable to access 'https://github.com/ElementUI/theme-default.git/': OpenSSL SSL_read: Connection was reset, errno 10054
npm ERR!
npm ERR! exited with error code: 128
解决办法
我们需要设置git环境
git config --global url.“https://”.insteadOf git://
然后重新运行 npm install就行或者npm install --registry=https://registry.npm.taobao.org使用淘宝镜像
执行之后,再次下载依赖,这时就正常下载了
npm ERR! code 128
npm ERR! command failed
npm ERR! command git ls-remote ssh://git@github.com/nhn/raphael.git
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.

解决办法
之所以是这样,是因为本地生成的SSH keys添加到github里面,,这个生成的SSH keys 是带有密码的

解决方法
 桌面右键,git bash here
 输入以下
 ssh-keygen -t rsa -C “你的邮箱名称”
 overwrite 输入y
 输入密码的时候直接回车
 重复密码输入还是直接回车,然后把github上以前的sshkeys删除,c盘->用户->你的用户名->.ssh->id_rsa.pub里边的字符添加到 github右上角头像->settings->ssh & GPG ->Add sshKeys
 第二个大框里输入确认即可
Module build failed: Error: Cannot find module 'node-sass'报错问题
用npm install -g cnpm --registry=https://registry.npm.taobao.org ,从淘宝镜像那下载(安装淘宝镜像出错,执行以下命令后,再尝试npm config set strict-ssl false),然后cnpm下载成功。

最后输入cnpm install node-sass --save。

npm run dev终于能跑起来了!!!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值