如何上传本地项目到Gitee的流程:
1.Gitee创建项目
![](https://file.jishuzhan.net/article/1717781653696286721/d5e4205123923b0b2b5e89200280cc9c.webp)
2. 进入所在文件夹,右键点击Git Bash Here
![](https://file.jishuzhan.net/article/1717781653696286721/90182da15abf304da7a4a95bedbff8d6.webp)
3.配置用户名和邮箱
在gitee的官网找到命令,注意这里的用户名和邮箱一定要和你本地的Git相匹配,否则会出现问题。
解决方法如下:https://blog.csdn.net/baoyin0822/article/details/122584931
bash
$ git config --global user.name "xxx"
$ git config --global user.email "xxx"
![](https://file.jishuzhan.net/article/1717781653696286721/0be94b03f937b744b346719bf06ed153.webp)
4. 初始化本地仓库,变为git管理仓库
bash
$ git init
![](https://file.jishuzhan.net/article/1717781653696286721/d04eb4bdde20406133ed6cde726b9841.webp)
5.添加项目下的文件
bash
$ git add . (注意有个点)
![](https://file.jishuzhan.net/article/1717781653696286721/43c9f75d1ec4525eefd5f9412546e43c.webp)
6.将文件添加到仓库
bash
git commit -m "first commit" (first commit 是添加说明,便于后期查看)
![](https://file.jishuzhan.net/article/1717781653696286721/3301b1620c99743fb370dc2cf8017146.webp)
7. 将本地代码与远程代码关联
bash
$ git remote add origin https://gitee.com/用户名/仓库名.git
![](https://file.jishuzhan.net/article/1717781653696286721/7f52887d5c8a639ae033c669e2f9e668.webp)
8. 强制把远程代码更新到当前分支。(若仓库为空,则忽略)
bash
$ git pull --rebase origin master
9. 本地代码推送到gitee仓库中
bash
$ git push -u origin master
这是需要输入gitee的用户名和密码,之后就会成功上传。
如果已经存在仓库
1.进入存在的仓库下
bash
cd existing_git_repo
2. 添加关联
bash
git remote add origin https://gitee.com/kitea2022/test.git
3. push
bash
git push -u origin "master"