1. Create a warehouse
Log yard cloud https://gitee.com/ create a warehouse
2. Use the git locally initialization
(1) Create a directory to store downloaded items, I created a "gitspace" folder on the D drive, used to store downloaded items
(2) enter just the new folder, that is, into "gitspace", click the right mouse button and select "Git Bash Here", as shown below:
After clicking "Git Bash Here", you can see the following interface
(3) Perform basic configurations, as a basic configuration of git, git role is to tell who you are, the information you enter will appear in your submission created, use the following two commands:
git config --global user.name "你的名字或昵称"
git config --global user.email "你的邮箱"
Results are as follows:
(4) Execute the following command in gitspace folder, complete initialization
git init
git remote add origin <你的项目地址> //注:项目地址形式为:https://gitee.com/xxx/xxx.git或者 [email protected]:xxx/xxx.git
Results are as follows:
(5) If you want to clone, only you need to execute the command
git clone <项目地址>
Results are as follows:
Pop-up window, enter the name of the account code of the cloud, password
Click "OK"
Look at gitspace folder already downloaded the
(6) into the directory you have initialized good or cloning project, and then execute:
# 从服务器下更新项目,因为已经clone过,所以不需要再更新
git pull origin master
3. submit the project to the cloud code
Do some changes in local projects, such as adding a "description .txt" files
execute the following command to complete the first submission
# 保存到缓存区,或 git add 被拖入的项目名
git add .
# 描述这次提交的内容 (推送到本地库中)
git commit -m “要描述的内容”
# 推送到远端仓库码云上,项目大的话,时间会久些
git push origin master
Note: If the last step in error, you can use git push -f origin master
to mandatory coverage.
git push origin master //(正常提交)和
git push origin master -f //(强制提交,强制提交可能会把之前的commit注释信息,不会改变修改的代码,慎用),都是提交到master分支
Other common git commands
View all branch: git branch -a
Switching to a branch: git checkout branchname
Merge branch: git merge original branch target branch
4. Update code to local
git status (see local branch file information, to ensure that no conflict of updates)
git checkout - [file name] (file if there are changes, you can revert to the original state; if files need to be updated to the server, you should merge to the server, and then update to the local)
git branch (branch to view the current situation)
git checkout remote branch
git pull
If the command is successful, the update code is successful!
It can be used directly: git pull command to update the code step
5. Review and modify user information
Modify the user name and password
git config --global user.name "username"
git config --global user.email "email"
Check your username and password
git config user.name
git config user.email