关于git push 后出现remote: HTTP Basic: Access denied等相关报错问题

###纪念首次写csdn博客
####关于git push 后出现***remote: HTTP Basic: Access denied*报错问题

分析:主要原因是首次输入的用户名或密码不正确,导致上传时验证失败,所以要重新设置,如下
执行:git config --system --unset credential.helper

####设置可能出现的问题***error: could not lock config file C:/Program Files/Git/mingw64/etc/gitconfig: Permission denied***

分析:没有管理员权限,虽然初步查找资料https://blog.csdn.net/aa20274270/article/details/50332623是这个说法,但是远水解不了近渴,后端的大神告诉我要以管理员身份运行cmd,更改–system配置
结果:成功

设置***全局的用户名和邮箱***,这也是gitLab创建仓库后会告诉我们要做的事情

操作:git config –global user.name “John Doe”
操作:git config –global user.email [email protected]

####如果本地有文件,想要提交到仓库

操作:1、git init
操作:2、git remote add origin < name >

那么添加多了,如何删除>>>操作git remote remove < name > ( https://blog.csdn.net/luodao_/article/details/79041918 写的很好

操作:3、git add .
操作:4、git commit -m"说明"
操作:5、git push -u origin master

关于创建仓库后仓库提示内容的说明

在这里插入图片描述

git仓库上也提供了相关的说明,在文件夹创建本地仓库并提交远程

git init
git add README.md
git commit -m "first commit"
git remote add origin git地址
git push -u origin master

或者是在原有的本地仓库提交到远程

git remote add origin https://github.com/hellenhellen/-.git
git push -u origin master

或者是通过import将代码直接导入到仓库

关于本地文件提交远程并创建分支的方法

  • 操作:1、git init
  • 操作:2、git add .
  • 操作:3、git commit -m"注释"
  • 操作:4、git remote add <名称> <git地址>
    • 注释: 这个时候可以通过git remote -v 查看所有提交的远程仓库,其中第一个字符就是提交的添加的名称,第二个是远程地址的名称。如下如,表示添加远程仓库成功。
    • 在这里插入图片描述
  • 操作:5、git branch <分支名>
    • 注意:创建分支前需要git add . 和git commit -m"",否则创建创建分支的时候会报如下错误:
      $ git branch demo
      fatal: Not a valid object name: 'master'.
      
  • 操作:6、git checkout <分支名>
  • 操作:7、git push -u <remote的远程仓库名> <本地分支名>
    • 注释:有说法说如果不在 分支下提交要这么使用git push origin branch_abc: branch_abc
    • 找到一个说明比较全而且实践起作用的博客http://www.cnblogs.com/springbarley/archive/2012/11/03/2752984.html

查看远程分支的方法

git branch -a
绿色为当前分支,红色为本地远程分支,HEAD表示默认指针指向的远程分支,也就是dev分支
在这里插入图片描述


哈哈哈,虽然内容简单,但是开心,如果有大神想交流前端,可加wc:wxnfn77 。

猜你喜欢

转载自blog.csdn.net/weixin_42737733/article/details/82178877