Git total solution idea github gitee gitlab

Git of Shang Silicon Valley Technology Course Series

Curriculum resources https://www.bilibili.com/video/BV1vy4y1s7k6

1. Git overview

Git is a free and open source distributed version control system, which can quickly and efficiently deal with all kinds of problems from small to large
project
Git is easy to learn, small footprint and extremely fast performance. It has cheap local library, convenient temporary storage area and multiple jobs
Flow branching and other characteristics. Its performance is better than version control tools such as Subversion, CVS, Perforce and ClearCase.

2. What is version control

Version control is a system that records the changes of file contents so that you can check the revision of a specific version in the future.
In fact, the most important thing of version control is to record the file modification history, so that users can view the historical version,
Facilitate version switching.

3. Why do I need version control

Transition from individual development to teamwork.

After the emergence of distributed version control system, the defects of centralized version control system are solved:

  1. Development can also be carried out when the server is disconnected (because version control is carried out locally)
  2. Each client also saves the whole complete project (including history, which is more secure)

4. Git working mechanism

5. Git and code hosting Center

Code hosting center is a remote code warehouse based on network server, which is generally simply called remote library.
Local area network
✓ GitLab
Internet
‡ GitHub (extranet)
‡ Gitee code cloud (domestic website)

6. Git common commands

6.1 setting user signature

Basic grammar

git config --global user.name user name
git config --global user.email mailbox

explain:
The function of signature is to distinguish the identity of different operators. The user's signature information can be seen in the submission information of each version
To confirm who made this submission. The first time Git is installed, the user signature must be set, otherwise the code cannot be submitted.
※ note: there is no responsibility to set the user signature and the account to log in to GitHub (or other code hosting Center) in the future
What does it matter.

6.2 initialize local library

Basic grammar

git init
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720
$ git init
Initialized empty Git repository in D:/Git-Space/SH0720/.git/

Result view

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-nhygp2d0-1643703496819) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220131193440211. PNG)]

6.3 viewing local library status

Basic grammar

git status

First view

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)

New file (hello.txt)

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ vim hello.txt
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!

View again (untraceable files detected)

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
No commits yet
Untracked files:
 (use "git add <file>..." to include in what will be committed)
 hello.txt
nothing added to commit but untracked files present (use "git add" 
to track)

6.4 adding staging area

Basic grammar

git add file name

example

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git add hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working 
directory.

View status (new file detected in staging area)

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
No commits yet
Changes to be committed:
 (use "git rm --cached <file>..." to unstage)
 new file: hello.txt

6.5 submit to local library

Commit files from staging area to local library

Basic grammar

git commit -m "log information" file name

example

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git commit -m "my first commit" hello.txt

warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working 
directory.
[master (root-commit) 86366fa] my first commit
1 file changed, 16 insertions(+)
create mode 100644 hello.txt

View status (no files to submit)

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status

On branch master
nothing to commit, working tree clean

6.6 modification of documents

Exit press esc to enter: wq

Insert press i

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ vim hello.txt

hello git! hello atguigu! 2222222222222
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
6.6.1 check the status (it is detected that there are files modified in the work area)
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
Changes not staged for commit:
 (use "git add <file>..." to update what will be committed)
 (use "git checkout -- <file>..." to discard changes in working 
directory)
 modified: hello.txt
no changes added to commit (use "git add" and/or "git commit -a")
6.6.2 add the modified file to the temporary storage area again
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git add hello.txt
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working 
directory.
6.6.3 viewing status (the modification of the work area is added to the staging area)
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git status
On branch master
Changes to be committed:
 (use "git reset HEAD <file>..." to unstage)
 modified: hello.txt

6.7 historical version

6.7.1 viewing historical versions

Basic grammar

git reflog View version information
git log View version details
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git reflog

087a1a7 (HEAD -> master) HEAD@{0}: commit: my third commit (head Point to header file)
ca8ded6 HEAD@{1}: commit: my second commit
86366fa HEAD@{2}: commit (initial): my first commit
Version 6.7.2 shuttle

Basic grammar

git reset --hard Version number
--First, check the current history. You can see that the current is 087 a1a7 This version
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git reflog

087a1a7 (HEAD -> master) HEAD@{0}: commit: my third commit
ca8ded6 HEAD@{1}: commit: my second commit
86366fa HEAD@{2}: commit (initial): my first commit


--Switch to 86366 fa Version, that is, the version we submitted for the first time
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git reset --hard 86366fa

HEAD is now at 86366fa my first commit


--Check the history after switching. At present, it has successfully switched to 86366 fa edition
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git reflog

86366fa (HEAD -> master) HEAD@{0}: reset: moving to 86366fa
087a1a7 HEAD@{1}: commit: my third commit
ca8ded6 HEAD@{2}: commit: my second commit
86366fa (HEAD -> master) HEAD@{3}: commit (initial): my first commit


--Then view the file hello.txt,It is found that the contents of the file have changed
$ cat hello.txt

hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!

For Git switching version, the bottom layer is actually a moving HEAD pointer. The specific principle is shown in the figure below

6.8 Git label

-a option means "create an annotated label"

$ git tag -a v1.0 

Git has commit. Why introduce tag?

"Please package and release the version from last Monday. The commit number is 6a5819e..."

"It's hard to find a bunch of messy numbers!"

If you choose another way:

"Please package and release the version from last Monday. The version number is v1.2"

"OK, just find the commit according to tag v1.2!"

Therefore, tag is a meaningful name that people can easily remember. It is tied to a commit.

6.8.1 creating labels
[root@Git git]# git tag v1.0
6.8.2 viewing existing labels
[root@Git git]# git tag
v1.0
[root@Git git]# git tag v1.1
[root@Git git]# git tag
v1.0
v1.1
6.8.3 deleting labels
[root@Git git]# git tag -d v1.1
Deleted tag 'v1.1' (was 91388f0)
[root@Git git]# git tag
v1.0
6.8.4 view the content modified in this version
[root@Git git]# git show v1.0
commit 91388f0883903ac9014e006611944f6688170ef4
Author: "syaving" <"819044347@qq.com">
Date: Fri Dec 16 02:32:05 2016 +0800
commit dir
diff –git a/readme b/readme
index 7a3d711..bfecb47 100644
— a/readme
+++ b/readme
@@ -1,2 +1,3 @@
text
hello git
+use commit
[root@Git git]# git log –oneline
91388f0 commit dir
e435fe8 add readme
2525062 add readme

7. Git branch operation


What is a branch?

In the process of version control, we can promote multiple tasks at the same time. For each task, we can create a separate version of each task
 Branch. Using branches means that programmers can separate their work from the main line of development
 Waiting time will not affect the operation of main line branches. For beginners, a branch can be understood as a copy
 A separate copy. (the underlying layer of a branch is actually a reference to a pointer)

Benefits of branching

At the same time, promote the development of multiple functions in parallel to improve the development efficiency.
During the development of each branch, if the development of one branch fails, it will not have any impact on other branches. fail
 Delete the branch and start again.

Branch operation

7.1 viewing branches

Basic grammar

git branch -v
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git branch -v

master 087a1a7 my third commit (*(represents the current partition)

7.2 create branch

Basic grammar

git branch Branch name
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git branch hot-fix

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git branch -v

hot-fix 087a1a7 my third commit (The new branch just created and the main branch master (a copy of the content of)
* master 087a1a7 my third commit

7.3 modify branch

--stay maste Make changes on the branch
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ vim hello.txt


--Add staging area
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git add hello.txt


--Submit local library
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git commit -m "my forth commit" hello.txt
[master f363b4c] my forth commit
1 file changed, 1 insertion(+), 1 deletion(-)


--View branch
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git branch -v
 hot-fix 087a1a7 my third commit (hot-fix Branch (no change)
* master f363b4c my forth commit (current master The branch has been updated to the latest commit
 (version of)


--see master File content on branch
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ cat hello.txt
hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 3333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! master test
hello git! hello atguigu!

7.4 switching branches

Basic grammar

git checkout Branch name
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git checkout hot-fix
Switched to branch 'hot-fix'


--It is found that the current branch has been master Change to hot-fix
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (hot-fix)
$
--see hot-fix File content discovery and on branch master The content on the branch is different
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (hot-fix)
$ cat hello.txt
hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 3333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!


--stay hot-fix Make changes on the branch
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (hot-fix)
$ cat hello.txt
hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 3333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! hot-fix test


--Add staging area
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (hot-fix)
$ git add hello.txt


--Submit local library
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (hot-fix)
$ git commit -m "hot-fix commit" hello.txt

7.5 consolidated branches

Basic grammar

git merge Branch name

Case practice: merge hot fix branches on the master branch

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git merge hot-fix
Auto-merging hello.txt
CONFLICT (content): Merge conflict in hello.txt
Automatic merge failed; fix conflicts and then commit the result.

7.6 conflict

Performance caused by conflict: the following status is MERGING

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master|MERGING)
$ cat hello.txt
hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 3333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
<<<<<<< HEAD
hello git! hello atguigu! master test
hello git! hello atguigu!
=======
hello git! hello atguigu!
hello git! hello atguigu! hot-fix test
>>>>>>> hot-fix

Causes of conflict:
When merging branches, two branches have two sets of completely different modifications in the same location of the same file. Git can't replace
We decide which one to use. The content of the new code must be determined manually.
View status (two modifications to the file detected)

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master|MERGING)
$ git status
On branch master
You have unmerged paths.
 (fix conflicts and run "git commit")
 (use "git merge --abort" to abort the merge)
Unmerged paths:
 (use "git add <file>..." to mark resolution)
 both modified: hello.txt
no changes added to commit (use "git add" and/or "git commit -a")

7.7 conflict resolution

Edit conflicting files, delete special symbols, and decide what to use
Special symbol: < < < code of current branch of head = = = = = = merged code > > > > > > Hot fix

hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 3333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! master test
hello git! hello atguigu! hot-fix test

Add to staging area

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master|MERGING)
$ git add hello.txt

Execute commit (Note: when using git commit command at this time, the file name cannot be taken)

Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master|MERGING)
$ git commit -m "merge hot-fix"
[master 69ff88d] merge hot-fix
--Find the back MERGING Disappear and become normal
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$

7.8 creating and switching branches

master and hot fix are actually pointers to specific version records. The current branch is actually created by HEAD
Decision. So the essence of creating a branch is to create one more pointer.
If the HEAD points to the master, we will now be on the master branch.
If HEAD executes hotfix, we will be on the hotfix branch now.

So the essence of switching branches is to move the HEAD pointer.

7.9 differences between git merge and git rebase*****

https://segmentfault.com/a/1190000018580144

Usage scenario interpretation

https://www.jianshu.com/p/4079284dd970

8. Git team collaboration mechanism

8.1 intra team collaboration

8.2 cross team collaboration

9. GitHub operation

9.1 establishment of remote warehouse

9.2 remote warehouse operation

9.2.1 creating a remote warehouse alias
Basic grammar
git remote -v View all current remote address aliases
git remote add Alias remote address
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git remote -v
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git remote add ori https://github.com/atguiguyueyue/git-shTest.git
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git remote -v    ((two are usually created)
ori https://github. com/atguiguyueyue/git-shTest. Alias of GIT (fetch) pull
ori https://github. com/atguiguyueyue/git-shTest. Git (push) alias for push
9.2.2 push local branch to remote warehouse

Basic grammar

git push Alias branch
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git push ori master
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': atguiguyueyue
Counting objects: 3, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 276 bytes | 276.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/atguiguyueyue/git-shTest.git
* [new branch] master -> master
9.2.3 clone remote warehouse to local

Basic grammar

git clone Remote address
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/pro-linghuchong
$ git clone https://github.com/atguiguyueyue/git-shTest.git
Cloning into 'git-shTest'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
9.2.4 invite to join the team

1) Choose to invite collaborators

2) Fill in people who want to cooperate

3) Copy the address and send it to the user through wechat nailing. The copied contents are as follows:
https://github.com/atguiguyueyue/git-shTest/invitations

4) Copy the link to receive the invitation in the address bar of atguigulinghuchong account, and click to accept the invitation

5) After success, you can see git test's remote warehouse on the account atguigulinghuchong

6) Linghu Chong can modify the content and push it to the remote warehouse.

--edit clone File down
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/pro-linghuchong/git-shTest
(master)
$ vim hello.txt


Layne@LAPTOP-Layne MINGW64 /d/Git-Space/pro-linghuchong/git-shTest
(master)
$ cat hello.txt
hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 33333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! I am the most handsome, more handsome than Yue buqun
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! master test
hello git! hello atguigu! hot-fix test


--Add the edited file to the staging area
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/pro-linghuchong/git-shTest
(master)
$ git add hello.txt


--Upload the files in the staging area to the local library
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/pro-linghuchong/git-shTest
(master)
$ git commit -m "lhc commit" hello.txt
[master 5dabe6b] lhc commit
1 file changed, 1 insertion(+), 1 deletion(-)


--The contents of the local library push To remote warehouse
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/pro-linghuchong/git-shTest
(master)
$ git push origin master
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': atguigulinghuchong
Counting objects: 3, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 309 bytes | 309.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/atguiguyueyue/git-shTest.git
 7cb4d02..5dabe6b master -> master

7) Returning to the GitHub remote warehouse of atguiguyueyue, you can see that the last time was submitted by lhc.

9.2.5 pull remote library content

Basic grammar

git pull Remote library address alias remote branch name
--Pull down the latest content of the remote warehouse for the branch and merge it directly with the current local branch
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ git pull ori master
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/atguiguyueyue/git-shTest
* branch master -> FETCH_HEAD
 7cb4d02..5dabe6b master -> ori/master
Updating 7cb4d02..5dabe6b
Fast-forward
hello.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)


Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ cat hello.txt
hello git! hello atguigu! 2222222222222
hello git! hello atguigu! 33333333333333
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! I am the most handsome, more handsome than Yue buqun
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu!
hello git! hello atguigu! master test
hello git! hello atguigu! hot-fix test

9.3 cross team collaboration

1) Copy the address of the remote warehouse to people who invite cross team cooperation, such as Dongfang invincible.

2) Copy the received link in the address bar of the East invincible GitHub account, and then click Fork to cross the project to self
Own local warehouse.

After fork

3) Eastern invincible can edit the crossed files online.

4) After editing, fill in the description information and click the green button in the lower left corner to submit.

5) Next, click the Pull request above and create a new request.

6) Back to Yueyue GitHub account, you can see a Pull request.

Enter the chat room to discuss the content related to the code.

7) If there is no problem with the code, you can click Merge pull reque to merge the code.

9.4 SSH password free login

[the external chain image transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-xvuyaoxf-1643703496852) (C: \ users \ honor \ appdata \ roaming \ typora \ user images \ image-20220201094500415. PNG)]

The specific operations are as follows:

stay windos It's yourself C:\Users\user name
--Enter the current user's home directory
Layne@LAPTOP-Layne MINGW64 /d/Git-Space/SH0720 (master)
$ cd


--delete.ssh catalogue
Layne@LAPTOP-Layne MINGW64 ~
$ rm -rvf .ssh
removed '.ssh/known_hosts'
removed directory '.ssh'


--Run command generation.ssh Secret key directory[Note: here-C This parameter is capitalized C]
Layne@LAPTOP-Layne MINGW64 ~
$ ssh-keygen -t rsa -C atguiguyueyue@aliyun.com
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Layne/.ssh/id_rsa):
Created directory '/c/Users/Layne/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Layne/.ssh/id_rsa.
Your public key has been saved in /c/Users/Layne/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:7CPfRLITKcYDhaqpEDeok7Atvwh2reRmpxxOC6dkY44 
atguiguyueyue@aliyun.com
The key's randomart image is:
+---[RSA 2048]----+
| .. |
| .. |
| . .. |
|+ + o . . |
|oO . = S . |
|X . .. + = |
|+@ * .. = . |
|X.&o+. o = |
|Eo+Oo . . |
+----[SHA256]-----+


--get into.ssh Directory view file list
Layne@LAPTOP-Layne MINGW64 ~
$ cd .ssh


Layne@LAPTOP-Layne MINGW64 ~/.ssh
$ ll -a
total 21
drwxr-xr-x 1 Layne 197609 0 11 19 / 25:27 ./
drwxr-xr-x 1 Layne 197609 0 11 September 25-19:27 ../
-rw-r--r-- 1 Layne 197609 1679 11 September 25-19:27 id_rsa
-rw-r--r-- 1 Layne 197609 406 11 September 25-19:27 id_rsa.pub


--see id_rsa.pub Document content
Layne@LAPTOP-Layne MINGW64 ~/.ssh
$ cat id_rsa.pub
ssh-rsa 
AAAAB3NzaC1yc2EAAAADAQABAAABAQDRXRsk9Ohtg1AXLltsuNRAGBsx3ypE1O1Rkdzpm
l1woa6y6G62lZri3XtCH0F7GQvnMvQtPISJFXXWo+jFHZmqYQa/6kOIMv2sszcoj2Qtwl
lGXTPn/4T2h/cHjSHfc+ks8OYP7OWOOefpOCbYY/7DWYrl89k7nQlfd+A1FV/vQmcsa1L
P5ihqjpjms2CoUUen8kZHbjwHBAHQHWRE+Vc371MG/dwINvCi8n7ibI86o2k0dW0+8SL+
svPV/Y0G9m+RAqgec8b9U6DcSSAMH5uq4UWfnAcUNagb/aJQLytrH0pLa8nMv3XdSGNNo
AGBFeW2+K81XrmkP27FrLI6lDef atguiguyueyue@aliyun.com

Copy id_rsa.pub file content, log in to GitHub and click user Avatar → Settings → SSH and GPG keys

[the external chain image transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-jfomy7d4-1643703496853) (C: \ users \ honor \ appdata \ roaming \ typora \ user images \ image-20220201094854007. PNG)]

10. Idea integration Git

10.1 configure Git ignore file (it has been automatically configured in idea)

Question 1: why ignore them?
A: it has nothing to do with the actual function of the project and does not participate in the deployment and operation on the server. Ignore them, which can shield IDE tools
Differences between.
Question 2: how to ignore?
1) Create ignore rule file XXXX Ignore (prefix name is optional, git.ignore is recommended)
In principle, the storage location of this file can be anywhere. In order to make ~ / gitconfig file reference, it is recommended to use it
Under household directory

git. The contents of the ignore file template are as follows

# Compiled class file
*.class
--------------—
46
 more Java –big data –front end –python For the download of artificial intelligence materials, please visit the official website of Baidu: Shang Silicon Valley
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see 
http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.classpath
.project
.settings
target
.idea
*.iml

2) Yes The gitconfig file refers to the ignore configuration file (this file is in the home directory of Windows)

[user]
name = Layne
email = Layne@atguigu.com
[core]
excludesfile = C:/Users/asus/git.ignore
 Note: use "forward slash" here(/)",Do not use backslashes(\)"

10.2 positioning Git program

[the external chain image transfer fails, and the source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-apmbr8ia-1643703496855) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201100549833. PNG)]

10.3 initialize local library

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-63xjcjqr-1643703496856) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201100612722. PNG)]

10.4 add to staging area

Right click the item and select git - > add to add the item to the staging area.

10.5 submit to local library

Right click the project and select git - > commit directory to add the project to the local library

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-ebhaow9y-1643703496857) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201100719120. PNG)]

10.6 switching versions

Lower right corner

[the external chain image transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (IMG rtihcowv-1643703496858) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201104312093. PNG)]

10.7 create branch

10.8 switching branches

10.9 consolidated branches

10.10 conflict resolution

The above four contents can be found in this article. idea2020 is applicable

https://blog.csdn.net/I_r_o_n_M_a_n/article/details/120800499

11. IDEA integration GitHub

11.1 set up GitHub account

[the external chain image transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-bj3uhgnj-1643703496861) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201133823970. PNG)]

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (IMG ncfgguba-1643703496862) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201133834528. PNG)]

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-5rtstdmy-1643703496863) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201133844075. PNG)]

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-lkueovo8-1643703496864) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201134216596. PNG)]

11.2 share the project to GitHub

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-ofegglco-1643703496865) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201142006284. PNG)]

11.3 push push local library to remote library

[the external chain image transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-ptuehx8g-1643703496866) (C: \ users \ honor \ appdata \ roaming \ typora \ typora user images \ image-20220201142021520. PNG)]

[the external chain image transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-h0ph56ss-1643703496867) (C: \ users \ honor \ appdata \ roaming \ typora \ typora user images \ image-20220201142036717. PNG)]

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-4mjamhsh-1643703496868) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201142058440. PNG)]

11.4 pull pull remote library to local library

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-ekd86fpu-1643703496869) (C: \ users \ honor \ appdata \ roaming \ typora \ typora user images \ image-20220201142125081. PNG)]

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-quckavsm-1643703496870) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201142133654. PNG)]

11.5 clone remote library to local

[the external chain image transfer fails, and the source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-zk0x95rq-1643703496871) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201142213100. PNG)]

[the external chain image transfer fails, and the source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-krgq5mia-1643703496872) (C: \ users \ honor \ appdata \ roaming \ typora \ typora user images \ image-20220201142222230. PNG)]

12. Domestic code hosting Center - Code cloud

As we all know, GitHub server is abroad. GitHub is used as the project hosting website. If the network speed is not good,
It will seriously affect the use experience and even fail to log in. In this case, you can also use domestic items
Target hosting website - Code cloud.

Code cloud is a Git based code Hosting Service Center launched by open source China. Its website is https://gitee.com/ , use
The way is the same as GitHub, and it is also a Chinese website. If your English is not very good, it is the best choice.

12.1 IDEA installation code cloud plug-in

Idea does not have a code cloud plug-in by default. The first step is to install the Gitee plug-in.
As shown in the figure, search for Gitee in the Idea plug-in store, and then click the Install button on the right

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-akdgyulz-1643703496873) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201142403197. PNG)]

12.2 IDEA connection code cloud

The connection code cloud of Idea is almost the same as that of GitHub. First, create a project in Idea and initialize git
Process, and then add the code to the temporary storage area and submit it to the local library. These steps have been described above and will not be repeated here.

The rest is the same as the appeal

13. Self built code hosting platform GitLab

13.1 introduction to gitlab

GitLab is developed by GitLab Inc Develop and use MIT licensed web-based Git warehouse management tool with
wiki and issue tracking. Use Git as a code management tool and build a web service on this basis.
Developed by Ukrainian programmers Dmitry zaporozhets and Valery sizov, GitLab is written in Ruby
Yes. Later, some parts were rewritten in Go language. As of May 2018, the company has about 290 team members to
And more than 2000 open source contributors. GitLab is supported by IBM, Sony, J ü Lich Research Center, NASA, Alibaba,
Invincea, O'ReillyMedia, Leibniz rechenzentrum (LRZ), CERN, SpaceX and other organizations.

13.2 GitLab official website address

Official website address: https://about.gitlab.com/
Installation instructions: https://about.gitlab.com/installation/

13.3 GitLab installation

13.3.1 server preparation

Prepare a server with a system of CentOS7 or above, which requires 4G memory and 50G disk.
Close the firewall and configure the host name and IP to ensure that the server can access the Internet.
This tutorial uses virtual machine: hostname: gitlab server IP address: 192.168.6.200

13.3.2 preparation of installation package

When installing gitlab CE online, Yum needs to download hundreds of M installation files, which is very time-consuming, so it's best to download them in advance
Download the required RPM package locally, and then install it using offline rpm.
Download address:

https://packages.gitlab.com/gitlab/gitlabce/packages/el/7/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm

Note: This rpm package is provided in the data. You can directly upload this package to the server / opt/module directory.

13.3.3 writing installation script

The steps of installing gitlab are cumbersome, so we can refer to the official website to write the installation script of gitlab.

[root@gitlab-server module]# vim gitlab-install.sh
sudo rpm -ivh /opt/module/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm
sudo yum install -y curl policycoreutils-python openssh-server cronie

sudo lokkit -s http -s ssh
sudo yum install -y postfix
sudo service postfix start
sudo chkconfig postfix on
curl https://packages.gitlab.com/install/repositories/gitlab/gitlabce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum -y install gitlabce

Add execution permission to the script

[root@gitlab-server module]# chmod +x gitlab-install.sh
[root@gitlab-server module]# ll
 Total consumption 403104
-rw-r--r--. 1 root root 412774002 4 July 15:47 gitlab-ce-13.10.2-
ce.0.el7.x86_64.rpm
-rwxr-xr-x. 1 root root 416 4 July 15:49 gitlab-install.sh

Then execute the script and start installing gitlab CE. Pay attention to ensure that the server can access the Internet.

[root@gitlab-server module]# ./gitlab-install.sh 
Warning:/opt/module/gitlab-ce-13.10.2-ce.0.el7.x86_64.rpm: head V4 
RSA/SHA1 Signature, secret key ID f27eab47: NOKEY
 In preparation... ################################# 
[100%]
Upgrading/install...
 1:gitlab-ce-13.10.2-ce.0.el7 
################################# [100%]
13.3.4 initialize GitLab service

Execute the following command to initialize GitLab service. The process takes about a few minutes. Wait patiently

[root@gitlab-server module]# gitlab-ctl reconfigure
.  .  .  .  .  . 
Running handlers:
Running handlers complete
Chef Client finished, 425/608 resources updated in 03 minutes 08 
seconds
gitlab Reconfigured!
13.3.5 start GitLab service

Execute the following command to start the GitLab service. To stop, execute GitLab CTL stop

[root@gitlab-server module]# gitlab-ctl start
ok: run: alertmanager: (pid 6812) 134s
ok: run: gitaly: (pid 6740) 135s
ok: run: gitlab-monitor: (pid 6765) 135s

ok: run: gitlab-workhorse: (pid 6722) 136s
ok: run: logrotate: (pid 5994) 197s
ok: run: nginx: (pid 5930) 203s
ok: run: node-exporter: (pid 6234) 185s
ok: run: postgres-exporter: (pid 6834) 133s
ok: run: postgresql: (pid 5456) 257s
ok: run: prometheus: (pid 6777) 134s
ok: run: redis: (pid 5327) 263s
ok: run: redis-exporter: (pid 6391) 173s
ok: run: sidekiq: (pid 5797) 215s
ok: run: unicorn: (pid 5728) 221s
13.3.6 accessing GitLab with browser

The GitLab service can be accessed by using the host name or IP address. You need to configure the windows hosts file in advance.

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-3rrefedz-1643703496874) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201145222611. PNG)]

[the external chain image transfer fails. The source station may have an anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-1sym9zt4-1643703496878) (C: \ users \ honor \ appdata \ roaming \ typora \ typora user images \ image-20220201145238511. PNG)]

13.3.7 GitLab create remote library

[the external chain image transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-tnzhgxxi-1643703496879) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201145317836. PNG)]

13.3.8 IDEA integration GitLab

1) Install GitLab plug-in

[the external chain image transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-tcjrvypl-1643703496880) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-20220201151457898. PNG)]

3) push local code to GitLab remote library

[the external chain image transfer fails. The source station may have anti-theft chain mechanism. It is recommended to save the image and upload it directly (img-dyl5fbag-1643703496881) (C: \ users \ honor \ appdata \ roaming \ typora user images \ image-202202011515299. PNG)]

Note: the link copied from gitlab web page is: http://gitlab.example.com/root/git-test.git ,
It needs to be manually modified as: http://gitlab-server/root/git-test.git
Select gitlab remote connection to push.

As long as the GitLab remote library connection is defined, pull and clone the GitLab remote library
Github is consistent with the code cloud, which will not be repeated here.

14. Classic interview questions

14.1 what is Git Flow and what are its benefits?

https://blog.csdn.net/ichen820/article/details/120371496

14.2 how to cancel the careless misoperation of submission?

https://www.cnblogs.com/waiting-ying/p/13288643.html

15 resources

video

⭐ [Shang Silicon Valley] 5h get through the full set of Git Tutorials - the latest IDEA version in 2021 https://www.bilibili.com/video/BV1vy4y1s7k6

book

Introduction to Git that monkeys can understand https://backlog.com/git-tutorial/cn/

⭐ GitHub roaming Guide https://github.phodal.com/

file

GitHub official documents: https://docs.github.com/cn

game

3s
ok: run: postgresql: (pid 5456) 257s
ok: run: prometheus: (pid 6777) 134s
ok: run: redis: (pid 5327) 263s
ok: run: redis-exporter: (pid 6391) 173s
ok: run: sidekiq: (pid 5797) 215s
ok: run: unicorn: (pid 5728) 221s

##### 13.3.6 accessing GitLab with browser

Use host name or IP Address to access GitLab Service. It needs to be prepared in advance windows of hosts Documents.

[External chain picture transfer...(img-3rrEfeDZ-1643703496874)]

[External chain picture transfer...(img-1sYm9ZT4-1643703496878)]

##### 13.3.7 GitLab create remote library

[External chain picture transfer...(img-TNZHGxxI-1643703496879)]

##### 13.3.8 IDEA integration GitLab

1)install GitLab plug-in unit

[External chain picture transfer...(img-TCjrvyPl-1643703496880)]

3)push Local code to GitLab Remote library

[External chain picture transfer...(img-dyl5fBAg-1643703496881)]

be careful: gitlab The link copied from the web page is: http://gitlab.example.com/root/git-test.git,
It needs to be manually modified as: http://gitlab-server/root/git-test.git
 choice gitlab Remote connection for push. 

as long as GitLab After defining the remote library connection of GitLab Remote library pull and clone Operation and
Github It is consistent with the code cloud and will not be repeated here.

### 14. Classic interview questions

##### 14.1 what is Git Flow and what are its benefits?

https://blog.csdn.net/ichen820/article/details/120371496

##### 14.2 how to cancel the careless misoperation of submission?

https://www.cnblogs.com/waiting-ying/p/13288643.html

### 15 resources

##### video

⭐[[Silicon Valley] 5 h Get through Git Full set of tutorials - latest in 2021 IDEA edition https://www.bilibili.com/video/BV1vy4y1s7k6

##### book

Monkeys can understand Git introduction https://backlog.com/git-tutorial/cn/

⭐ GitHub Roaming Guide https://github.phodal.com/

##### file

GitHub Official documents: https://docs.github.com/cn

##### game

Learning Git Branching: https://learngitbranching.js.org/?locale=zh_CN

Keywords: git github intellij-idea

Added by zeberdeee on Wed, 02 Feb 2022 09:00:12 +0200