git command use

1. First, you need to install Git, if it is already installed, please skip it. Since Git is developed on Linux, most of it is used on Linux systems, but there will definitely be a Windows version. I am using win10, just download and install: https://git-for-windows.github.io/

2. After installing the git server. First find the folder of your project, for example, the project name is myproject, enter this folder, right-click to open a command window that simulates linux style, and 
write picture description here 
then execute the commands in sequence:

git init   // 初始化版本库
git add .   // 添加文件到版本库(只是添加到缓存区),.代表添加文件夹下所有文件 
git commit -m "first commit" // 把添加的文件提交到版本库,并填写提交备注
  • 1
  • 2
  • 3
  • 4
  • 5

So far, we have completed the initialization of the code base, but the code is local and has not been submitted to the remote server, so the key is here. To submit it to the remote code server, perform the following two steps:

git remote add origin 你的远程库地址  // 把本地库与远程库关联
git push -u origin master    // 第一次推送时
git push origin master  // 第一次推送后,直接使用该命令即可推送修改
  • 1
  • 2
  • 3
  • 4
  • 5

Push the contents of the local library to the remote. Using the git push command actually pushes the current branch master to the remote. After executing this command, you will be asked to enter the user name and password, and the upload will start after the verification is passed. 
Note: The username and password need to be created by the command ssh-keygen -t rsa -C "[email protected]", and the obtained secret key (public key) file must be placed on the git server, so that you have the right to code push

At this point, the local code has been successfully placed on the remote server, so that the project team members can write and develop.

 

Hereby share, I hope to be useful to everyone.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326245759&siteId=291194637