Process: The whole process of adding git from the virtual machine and successfully submitting to GitLab

Ⅰ. Preparation:

1. GitView:

First, the command:git --version

// At this time, the version that can be seen in the virtual machine environment gitis:git version 2.41.0

insert image description here

Second, how to install on a virtual machine git:

A. Command:sudo apt-get install git
B. Then enter the virtual machine password:

// Note:
the command cd ..is to return to the previous folder (note: there is a space in the middle);
at this time, gitthe installation is under the work folder, so workthe files under this folder can be submitted to the code warehouse;

insert image description here

2. Create a folder to be submitted:

First, Linuxcreate a folder command ( mkdir + '待创建文件夹名称'):

mkdir frs_web_push

insert image description here

Second, switch to frs_web_pushthe directory command:

cd frs_web_push

insert image description here

3. Use comparethe tool to modify the code to be submitted;

Ⅱ. Submission process:

1. Enter gitthe command: git status .(Note: there is a space in the middle)

// Command entered work/frs_web_push/frsunder :

2. Enter gitthe command: git add .(Note: There is a space in the middle;)

insert image description here

3. Enter gitthe command: git commit -m"待输入的信息"(note: there is a space in the middle)

insert image description here

4. You may encounter the problem that user.emailand user.nameare not set (this is used at this time SSH 密匙):

First, first get emailthe value:

A. Enter the command in the virtual machine:cat ~/.ssh/

// At this point you can usually find:id_rsa.pub

B. Enter the command again in the virtual machine:cat ~/.ssh/id_rsa.pub

// At this point, you can get a key and the value of (that is, you can get the value of emailat the end after the command is entered ):email

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC69nohuvDnagn0vbHUATsiXZzQWQK2trAFASYyzcWxFJKCXBBqCvQzsp7+eh+VsIdLqZOf7ENR2Zc4nOaZ3yw1uWa4yv/PcMxOrV/DRE+1NOJxtL0LA5KNwy6QqD5rWhwTQ2nzLtfqU2cbbuqMXRS46Inaq44PMke0CEHXOQgEo95RoeUSZfOygj6Yswaw2ocEnkYme+upUq+B683D4CW+Qy/2XtUUCztuUL/Dc4+hSwfC1QW5L55KMxYZ54P1tqOJ1mavtGH6UojJ9JQ48E1nAiFBRvtznLc4+E5cjxgGN7znFSIrD1jneE2bMRr7fysH36Jg6MrBqem/rDbJ0dgk72pvWGDq+jCKiKQSPZYMz1E4cSlLpE6jT2+h3MxQxZXnmAoG6lxlDLdE907IG0r1cTKYPqiH9DNOVIucGQWm0xA++Oz+9T+5g9X9GPxI6oKUwMPam9hmV+i20i8p69zHxPhNRlNFTHJ7Bs2JvAoG9bEpbud3iGByejQtuey6zSfE0AIq4ZZjE7/Nsqi15DMxp263gqGl/bMf0q2y0aSzCJQfcs3JWUYLl8TZBUaeUVewhbi5XkgFfqw8HaJQIBK3Qy9HNRdwt/eN7NXxEddS100m88PoYHirUvU6sZL4umzMQtP6TFHeBDA7Sx7Xl5FZHf0ufRcAudf+VHXbWGT63w== *******@kemacom.com

Second, set user.emailthe command:

// At this point, GitLabthe email uploaded to can be successfully set;

git config --global user.email *******@kemacom.com

insert image description here

Third, set user.namethe command:

// At this point, GitLabthe name uploaded to can be successfully set;

git config --global user.name *******

insert image description here

Fourth, enter the submitted command:

git commit -m"*********"

insert image description here

Fifth, view the command of the git branch:

git branch -a

insert image description here

Sixth, gitthe command to push the content to the (new) branch via:

git push origin main:dev-web-*******

// At this point, the code you want to update can be successfully passed to the corresponding code warehouse (ie: successfully submitted to GitLab);

insert image description here

Seventh, there may be gitwrong commands pushed to the branch:

A、git push origin main

// An error will be reported at this time: it is not allowed to merge on mainthe main branch due to the protection of the project branch;

insert image description here

B、git push origin

// An error will be reported at this time: it is not allowed to merge on originthe main branch due to the protection of the project branch;

insert image description here

C. Reason analysis:

Because mainthe and originbranch need to create a new branch based on this basis to submit the code to be merged;
therefore, when it is necessary to submit, manually create a branch, such as: git push origin main:dev-web-*******
(Note: When gitcreating a new branch, it is generally based on a certain branch first ( Such as: origin 或 main) Create a new branch, and then gitmerge it according to the command, but in the virtual machine, you can directly create a new branch based on a certain branch during the submission process)

Eighth, view gitthe commands of all branches in:

git branch -r

// At this point, all the branches in the code warehouse can be displayed on the page (at this time, you can find your own newly created branches dev-web-*******):

insert image description here

Ⅲ. Other useful command lines:

1. The command to return to the previous directory in the virtual machine: cd ..(Note: there is a space in the middle and a gap with the previous command)

insert image description here

2. View the command of this directory in the virtual machine: ls(Note: there is a gap with the previous command)

insert image description here

3. View the command of the directory starting with a in the virtual machine: cd a(Note: there is a space in the middle and there is a gap with the previous command)

insert image description here

Ⅳ. Summary:

First, where there is something wrong or inappropriate, please give me some pointers and exchanges!
Second, if you repost or quote the content of this article, please indicate the address of this blog https://blog.csdn.net/weixin_43405300 . Creation is not easy, but it can be done and cherished!
Third, if you are interested, you can pay more attention to this column (Vue (Vue2+Vue3) interview must-have column): https://blog.csdn.net/weixin_43405300/category_11525646.html?spm=1001.2014.3001.5482

Guess you like

Origin blog.csdn.net/weixin_43405300/article/details/132057901