Configuring Git for Mac OS

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 --versionit for verification. If we have successfully installed it, we can see the result as shown in the figure below.
[(https://note.youdao.com/yws/res/6236/WEBRESOURCEf7095f7022a1eda0883bef133cdaf65e)]

Configure Gitee

generate key pair

First, we cd ~/.sshenter 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.
insert image description here

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 catobtain the file content through instructions. As shown below.
insert image description here

We will copy the obtained key pair and paste it into Gitee. Paste the location as shown below.
insert image description here

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.
insert image description here

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 initin to initialize our repository. As shown below.

insert image description here

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.

(https://note.youdao.com/yws/res/6295/WEBRESOURCE881a86d0c078ab42d6a7b28deeede24c)]

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.

insert image description here

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.

insert image description here

Guess you like

Origin blog.csdn.net/weixin_50153843/article/details/128528334