1. 新建远程仓库
2. 新建本地仓库
-
新建一个本地文件夹
-
在文件夹中打开GitBash
git config --global user.name fau152 #设置提交用户名为fau152 git config --global user.email [email protected] #设置提交邮箱 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到远程仓库
需要注意的问题:
-
缺少安全认证,提示:
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
-
提示:
warning: LF will be replaced by CRLF
解决办法:
git config --global core.autocrlf false
参考:git提示“warning: LF will be replaced by CRLF”的解决办法_青崖林夕的博客-CSDN博客
-
提交不上去,提示:
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 [email protected] #设置提交邮箱
用于设置本地邮箱为gitee官网给的用于提交的邮箱。
-