Puge - Yunyan team - the latest Git related configuration, integrated with IDEA

Posted by Ell20 on Mon, 17 Jan 2022 22:56:44 +0100

Git -- version control tool

1. What is Git:

Git is a version control tool,

Common version control tools:

​ Git,SVM,CVS,VSS,TFS,Visual Studio Online

Functions of version control tools:

  • Realize multi person collaborative development across regions
  • Track and record the history of one or more documents
  • Organize and protect your source code and documents
  • Statistical workload
  • Parallel development to improve development efficiency
  • Track and record the whole software development process
  • Reduce the burden on developers, save time, and reduce perceived errors

Differences between Git and SVM

SVM
SVN is the abbreviation of subversion. It is an open source version control system. Through the efficient management of branch management system, in short, it is used for multiple people to jointly develop the same project, share resources and realize the final centralized management.
——Baidu entry

Git

Git (pronounced / g) ɪ t /) is an open source distributed version control system, which can effectively and quickly deal with project version management from very small to very large. [1] It is also an open source version control software developed by Linus Torvalds to help manage Linux kernel development.

2. Git installation and configuration (local storage)

1. Download the git installation package on the git official website

git official website:

2. Install git tool:

Go on to the next step. If you need to know the contents of the corresponding settings, you can understand them yourself. I won't repeat them here.

When configuring the installation directory, you can modify it according to your own needs

3. Signs of successful installation:

Right click in any directory and the following two will appear in the menu

4. GitHub initializes the local library:

Create local warehouse

//Create local warehouse
ysd@����һ������ MINGW64 /f/Git
$ mkdir Git_Warehouse_configure

//Enter the folder of the local warehouse:
ysd@����һ������ MINGW64 /f/Git
$ cd Git_Warehouse_configure/

//Download the corresponding Git dependency
ysd@����һ������ MINGW64 /f/Git/Git_Warehouse_configure
$ git init
Initialized empty Git repository in F:/Git/Git_Warehouse_configure/.git/

//After downloading, use the ls -lA command to open it, and the display is displayed git's hidden folder shows that the download is correct
ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ ls -lA
total 4
drwxr-xr-x 1 ysd 197609 0 Jul 11 19:27 .git/

//Open Contents in git directory
ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ ll .git
total 7
-rw-r--r-- 1 ysd 197609  23 Jul 11 19:27 HEAD
-rw-r--r-- 1 ysd 197609 130 Jul 11 19:27 config
-rw-r--r-- 1 ysd 197609  73 Jul 11 19:27 description
drwxr-xr-x 1 ysd 197609   0 Jul 11 19:27 hooks/
drwxr-xr-x 1 ysd 197609   0 Jul 11 19:27 info/
drwxr-xr-x 1 ysd 197609   0 Jul 11 19:27 objects/
drwxr-xr-x 1 ysd 197609   0 Jul 11 19:27 refs/

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)

5. Set signature

Project level signature setting and viewing

Set user name (optional)
$ git config user.name Y_King
 Set the email address (this can be filled in at will, only for identification)
$ git config user.email Y_King@puge.com

After setting, view the configuration file
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[user]
        name = Y_King
        email = Y_King@puge.com

System user level signature setting and viewing

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ git config --global user.name Y_King

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ git config --global user.email Y_King@puge.com

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ cd ~

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 ~
$ pwd
/c/Users/ysd

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ cd ~


ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 ~
$ ls -lA|less

[2]+  Stopped                 ls -F --color=auto --show-control-chars -lA | less

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 ~
$ cat .gitconfig
[user]
        name = Y_King
        email = Y_King@puge.com

ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 ~
$ cat ~/.gitconfig
[user]
        name = Y_King
        email = Y_King@puge.com


6. Add submit and view operations

View the upload status of the current file
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   good.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        guil_parent/
ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ git add guli_parent
fatal: pathspec 'guli_parent' did not match any files
ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ git status
On branch master
No commits yet

Changes to be committed:
No commits yet --cached <file>..." to unstage)
        new file:   good.txt
Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   good.txto include in what will be committed)
        guil_parent/
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        guil_parent.zip /f/Git/Git_Warehouse_configure (master)
        guil_parent/t.zip
fatal: pathspec 'guli_parent.zip' did not match any files
ysd@▒▒▒▒һ▒▒▒▒▒▒ MINGW64 /f/Git/Git_Warehouse_configure (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   good.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        guil_parent.zip
        guil_parent/

//Open the vim command interface to modify the file (generally used to add file annotations)
$ vim good.txt

Setting instructions in vim interface:
: set nu displays the number of lines for the contents in the file
i annotate the file
Press Esc to exit text editing mode
: wq save changes and propose

//Commit file to cache
$ git add good.txt

//View the status of the current warehouse
$ git status

7. View log

//Show slim log content
$ git log
commit 507c5f6b9826870329f8fa4fac2d1c2b8f5d36e9 (HEAD -> master)
Author: Y_King <Y_King@puge.com>
Date:   Mon Jul 12 23:42:21 2021 +0800
    My first commit.new file good.txt and BannerAdminController.java
	//When too much content is displayed: multi screen control display:
		Space      Page down
		b 		 Page up 
		q		 Launch log interface
//1. Log contents are displayed in a single line
 git log --pretty=oneline
//2. Display log content in a single line: shorten the hash value of the query
$ git log --oneline

// How many steps are required to query the current version and move to the corresponding version
$ git reflog

Log display:

3. Git (Linux) command

View current directory

pwd
/f/Git/Git_Warehouse_configure

View the details of all files in the current folder

ls
BannerAdminController.java Demo01.txt good.txt guil_parent/ guil_parent.zip

create a file

touch index.js

Delete files (only files can be deleted, not folders)

rm index.js

Open file

cat file name

New folder

mkdir test

remove folders

rm -r guil_parent

Move the file to the specified folder (the following is to move the index.html file to the test folder)

mv index.html test

View history commands

history

View Git configuration information

git config -l

View Git's system configuration

git config --system --list

View user configuration information

$ git config --global --list
user.name=Y_King
user.email=Y_King@puge.com

Git command to add files locally

#Add all files in the warehouse to the staging area
git add .
# Add files to the local Git repository
git commit -m "Comments on uploaded files"
#View the status of the current file upload
git status

4. Create git in any folder through git command:

Construction of local warehouse ()

Step 1: create a new warehouse (create a new folder as a local warehouse)

mkdir gitcode

Part II: download configuration

git init

Cloning of remote warehouse: directly pull the remote warehouse to the local

git clone Resource path

5. File upload status

Four states of files

Ignore file

When uploading files, not all files need to be uploaded, so you need to filter the uploaded files and only upload the required files

,

Practical examples:

Use of code cloud

1. After registering the personal account number and setting the basic letter

2, * configure the SSH public key of the machine to realize secret free login

3. Steps of configuring local public key (realizing secret free login):

Locate the storage folder for the local public key

C:\Users\ysd.ssh

Open the folder and use the git command to generate the local key:

There are two ways to generate a secret key:
(1)ssh-keygen 

(2)	ssh-keygen -t rsa -C "github Registered mailbox name"

Since then enter OK, prompt for password, optional

We need to find a pair with id_dsa or id_rsa named files, one with Pub extension The pub file is your public key and the other is the corresponding private key. If such files cannot be found (or there is no. ssh directory at all), you can create them by running the ssh keygen program.

Then configure the local key to Gitee (the configured public key is the public key information with suffix. pub in the generated file above, with only one line):

Code cloud SSM configuration address

Integrating Git with IDEA

1. Pull the created warehouse to the specified local folder:

git clone Resource path

2. Integrate the created java project with Git

Mode 1:

When creating a Java project, specify the root directory location of the project as the above configured pull to the local warehouse

Mode 2:

After creating the Java project, copy and paste all the files pulled to the local warehouse into the folder of the Java project to overwrite the duplicate files

3. After the initial configuration is successful, the following contents will appear on the IDEA:

This indicates that the preliminary configuration has been completed:

However, there may be some problems, which are described below

Here are the general steps for uploading to Git:

Return after submitting successfully:

Check whether Git warehouse has been submitted:

Problems encountered in using Git:

In the local Git warehouse:

git: Your branch and 'origin/master' have diverged

Conflict resolution after Git branch renaming

Use the git command to forcibly overwrite duplicate branches

solve:
Method 1:
1,git pull origin master --allow-unrelated-histories [Allow irrelevant history submission and force consolidation]
Method 2:
1,git push --force origin master [[mandatory submission]

If there are deficiencies, or incorrect areas and areas that need to be improved, I hope you can leave a message in the comment area and change it in real time
If you have any help, please give me some support. Thank you. Old fellow.

On the way of self-study, you and I stick to it together. Come on, bald babies

Topics: Java git