使用gitee管理项目(git指令版)

发布时间 2023-03-23 21:15:27作者: fau152

1. 新建远程仓库

image-20230323205859055

image-20230323205922409

2. 新建本地仓库

  1. 新建一个本地文件夹

  2. 在文件夹中打开GitBash

    git config --global user.name fau152   	#设置提交用户名为fau152
    git config --global user.email 8994750+fau152@user.noreply.gitee.com  #设置提交邮箱
    git config --global http.sslVerify true
    git config --global core.autocrlf true
    git init  #初始化本地库
    git remote add origin https://gitee.com/fau152/stm32_template.git   #关联远程库,取别名为origin
    git pull --rebase origin master  #拉取远程仓库的文件到本地(主要是readme.md)
    git add .  #将本地所有的文件添加到本地库
    git commit -m "first commit"  #提交文件到本地库
    git push origin master  #push到远程仓库
    

    需要注意的问题:

    1. 缺少安全认证,提示:

      warning: ----------------- SECURITY WARNING ----------------
      warning: | TLS certificate verification has been disabled! |
      warning: ---------------------------------------------------
      warning: HTTPS connections may not be secure. See https://aka.ms/gcmcore-tlsverify for more information.
      

      解决办法:执行git config --global http.sslVerify true

    2. 提示:warning: LF will be replaced by CRLF

      解决办法:git config --global core.autocrlf false

      参考:git提示“warning: LF will be replaced by CRLF”的解决办法_青崖林夕的博客-CSDN博客

    3. 提交不上去,提示:

      remote: Powered by GITEE.COM [GNK-6.0]
      remote: error: GE007: Your push would publish a private email address.        
      remote: You can make your email public or disable this protection by visiting:        
      remote: https://gitee.com/profile/emails
      remote: error: hook declined to update refs/heads/master        
      error: failed to push some refs to 'https://gitee.com/ck_567/leet-code-practice.git'
      To https://gitee.com/ck_567/leet-code-practice.git
      !	refs/heads/master:refs/heads/master	[remote rejected] (hook declined)
      Done
      

      原因:gitee上设置了不公开邮箱地址,而本地提交的时候使用个人邮箱去提交的,所以被拦截

      解决办法:

      git config --global user.name fau152   	#设置提交用户名为fau152
      git config --global user.email 8994750+fau152@user.noreply.gitee.com  #设置提交邮箱
      

      image-20230323204345948

      用于设置本地邮箱为gitee官网给的用于提交的邮箱。