1. Create a Gitee repository
- Go to Gitee official website and create a new warehouse
- Configure the new warehouse
When initializing the warehouse, add a .gitignore item. It is recommended to keep the default unselected state.
[Experience of adding .gitignore template]: As long as you add .gitignore template or "use readme to initialize this warehouse", you need to generate the corresponding files (.gitignore and README.md), and the master branch will be initialized, which is not the same as the local master branch. Association, resulting in submission errors.
2. Upload local projects
- Go to the folder where the local project is located, right-click and select
Git Bash Here
[External link image transfer failed, the source site may have anti-theft right-click and select Git Bash Here]! For the link mechanism, it is recommended to upload https://(blog.csdn2mg.cn/c49X24bFifY14b434571910c1) ©eb]6ce2d3.png
If you have just installed Git, you need to configure Git [If the configuration has been completed, you can skip this step]
git config --global user.name "【你的Gitee的用户名】"
git config --global user.email "【你的Gitee绑定的邮箱】"
- Use the following command to check whether the creation is successful
git config --list
1. Entergit init
git init
Used to initialize an empty git local repository. After executing the above command, a .git hidden folder will be automatically generated in the current directory. This hidden folder is the git repository.
2. Create a .gitignore file in the project to configure and filter files that do not need to be uploaded (you can skip the files that are not required for this configuration)
Various .gitignore template configurations on GitHub
For example: (for reference only)
# Build Tools
.gradle
/build/
!gradle/wrapper/gradle-wrapper.jar
target/ #过滤target文件夹下的内容
!.mvn/wrapper/maven-wrapper.jar
# IntelliJ IDEA
.idea
*.iws
*.iml
*.ipr
# Vue
**/node_modules #过滤node_modules文件夹
**/.idea
dist
Use git status
to view the files that can be uploaded
git status
3.Inputgit remote add origin 你的仓库地址
Function: Bind local warehouse and remote warehouse
git remote add origin [远程仓库的具体地址]
4.Inputgit add .
Function: Add files to the temporary storage area
git add .
5. Entergit commit -m "【自定义的提交信息】"
Function: Bind local warehouse and remote warehouse
git commit -m "自定义的提交信息"
6.Inputgit pull origin master
Notice:An error may be reported here:
fatal: refusing to merge unrelated histories
Reason:
There is no correlation between the local library and the remote library. The local library needs to be pushed to the remote terminal. The remote terminal thinks that the local library is not related to it, so it is informed that it cannot be merged.
Solution:
Add --allow-unrelated-histories after the operation command to become:
git pull origin master --allow-unrelated-histories
git pull origin master --allow-unrelated-histories
7. Inputgit push origin master
Function: Upload the local branch version to the remote and merge it
After success, go to the warehouse to view:
At this point, the entire process of uploading local projects to the Gitee warehouse has been completed. Relevant content will be updated in the future. If there are any deficiencies, please correct me. You are welcome to leave a message in the comment area.