Download Git
When installing git on mac, generally only one line of instructions is requiredbrew install git
Verify Git
After we have installed Git, we can enter git --version
it for verification. If we have successfully installed it, we can see the result as shown in the figure below.
Configure Gitee
generate key pair
First, we cd ~/.ssh
enter our key pair folder, and create one ourselves if it does not exist. When creating a folder command mkdir .ssh
. After creating the folder, enter the cd folder command to enter the .ssh folder directory.
Executing ssh-keygen -t rsa -C 你的git邮箱
such an instruction can generate a key pair, but you must remember that this email address must be the same as the corresponding email address of your Gitee, etc. If they are different, some problems may occur later.
After entering the command, you will be prompted for a filename. After entering the file name, press Enter, you will be asked to enter the password, no matter, continue to press Enter, and then press Enter.
Next, we need to obtain our key pair, and we cat
obtain the file content through instructions. As shown below.
We will copy the obtained key pair and paste it into Gitee. Paste the location as shown below.
Finally we type in our terminal
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"
This completes our configuration.
try to push a piece of code
We first switch our path to the folder of any code. As shown in the picture below, I switched to one of our demo folders.
Next, we start to create a warehouse. The first step is to create a warehouse locally, because Git also performs a version management locally, and Gitee or GitHub just changes it to the Internet. So one is local and the other is network. Then we only need to type git init
in to initialize our repository. As shown below.
Next, we need to add our code. Then we can use it directly git add *
or add it one by one, then just enter git add 文件名
. After all, it needs to be marked for a while. If you add them one by one, you can separate the labels and make them look clearer to others.
In the next step, we will mark the added files and tell others what my file is for or what problems I have modified in this upload, etc. the command isgit commit -m "你要说的话"
Finally we connect to our remote repository with one line of command git remote add origin 仓库地址
. Warehouse address if not found. You can take a look at the position in the picture below on our webpage.
Finally, we can upload our code to our remote warehouse. Enter the command git push -u origin "master"
to see the following effect, which means the upload is successful.