Git Gitee上传仓库随手笔记

Git Gitee上传仓库随手笔记

      • 1、上传代码命令
      • 2、出现的问题及解决办法
          • (1). 输入git add . 命令之后出现警告
          • (2). git commit -m " 提交" 命令报错
          • (3). 输入git push -u origin master 命令报错

1、上传代码命令

右键需要上传的文件夹,点击Git Bash here,若是新仓库输入以下全部命令,若不是则只用输入3、4、5命令

  1. git init #初始化
    运行结果:
    在这里插入图片描述

  2. git remote add origin + 自己远程仓库地址 #与仓库建立连接

  3. git add . / git add -A #注意add后面“.”表示添加到暂缓区,“-A”表示添加全部文件

  4. git commit -m "提交的备注信息"
    运行结果:
    Git Gitee上传仓库随手笔记_第1张图片

  5. 新仓库输入: git push -u origin master ;若不是第一次提交则输入:git push origin master #回车后会出现让你输入gitee账号密码的对话框,输入之后点确定就完成了
    运行结果:
    Git Gitee上传仓库随手笔记_第2张图片

2、出现的问题及解决办法

(1). 输入git add . 命令之后出现警告
warning: LF will be replaced by CRLF in ... 
The file will have its original line endings in your working directory

原因:Git默认配置替换回车换行成统一的CRLF,路径中存在 / 的符号转义问题,相当于把路径的 / 符号进行转义,我们只需要修改配置禁用该功能即可

解决办法:输入以下命令

git config --global core.autocrlf false

(2). git commit -m " 提交" 命令报错
Please tell me who you are.
Run
  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got '...')

解决办法:找到项目中(注意是你的项目中)的.git文件夹,打开之后找到config文件,在最后添加:

[user]
email=your email
name=your name

注意:your email 和your name随便写上就行

(3). 输入git push -u origin master 命令报错
fatal: unable to access "...": could not resolve host: gitee.com

解决办法:运行命令:
git pull origin master
之后再运行:
git push -u origin master

你可能感兴趣的:(git,gitee,github)