git installation and gitee use (based on IDEA)

1. git installation

1.1: Download the installation package

(Please note that if you are not familiar with the meaning of each option, please keep the default option)
Git-2.18.0-64-bit.exe
open http://msysgit.github.io/ website, click Download to download the latest version

1.2: Installation tutorial

After the download is complete, start the installation.
Insert picture description here
Click Next.
Insert picture description here
Click Next
Insert picture description here
. Modify the installation path according to the situation. Click Next.
Insert picture description here
Cancel the Windows Explorer integration option and use TortoiseGit (recommended) and click Next.

Insert picture description here
Set the name in the start menu (default) and click Next

Insert picture description here
Select Use Git from the Windows Command Prompt (recommended) and click Next

Select the newline format (default) and click Next
Select the newline format (default) and click Next

Insert picture description here
Click Next to start the installation. The
Insert picture description here
installation is complete.
Insert picture description here
Check whether the installation is successful. Open the cmd inputgit --version

2. Git configuration

2.1. Generate public and private keys

[Start]—[git]—[git-bash]: Enter the following command
ssh-keygen -t rsa -C "Mailbox"

Insert picture description here
Note: The content of id_rsa.pub is added to gitee, so that your local id_rsa key is paired with the id_rsa.pub public key on gitee, and the code can be submitted after authorization is successful.

2.2 Add SSH key on gitee

Register an account on gitee https://gitee.com/

Copy the generated ssh key, and add the generated public key to the warehouse via "Management" -> "Deployment Public Key Management" -> "Add Deployment Public Key" on the warehouse homepage.
Insert picture description here
Insert picture description here

2.3. Test whether the match is successful

After adding, enter in the terminal (Terminal)

ssh -T [email protected]

For the first use, you need to confirm and add the host to the local SSH trusted list. If it returns Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access. content, it proves that the addition is successful.

Insert picture description here
After the addition is successful, you can use the SSH protocol to operate the warehouse

2.4. Configure username and email (git-bash use the following command)

We know that every commit we make will generate a log, this log marks the name and email of the submitter,
so that others can easily view and contact the submitter, so the first step when we submit the code is to set up ourselves Username and email. Execute the following code:

git config --global user.name “chan-kate”

git config --global user.email “[email protected]

3. Operation steps (in the console of idea)

3.1 Idea writing .ignore file

This is the file that is ignored when IDEA packages the project, because many of our IDEA projects are its own files, which have nothing to do with the project, so it is best to ignore other files when packaging into a war package
This file is placed at the root node of the project

#mac files
*/.DS_Store
.DS_Store


#java project files
*.class             #忽略所有.class 结尾的文件
bin/                #表示忽略当前路径下的bin文件夹,该文件夹下的所有内容都会被忽略,不忽略 bin 文件
/bin                #忽略根目录下的bin文件
*.log


#eclipse
*.iml
out/
/out
target/
/target


#myeclipse  idea local files
#任何目录下的.settings/下的文件
**/.settings/
**/.settings

#忽略所有以.classpath文件结尾的文件
*.classpath
**/*.classpath
*.project
*.log
**/*.class

 #表示忽略当前路径下的bin文件夹,该文件夹下的所有内容都会被忽略,不忽略 bin 文件
bin/
#忽略根目录下的bin文件
/bin

#忽略META-INF 以及该文件夹下的所有文件
META-INF/


build/


*/.idea/
.idea/
gradlew
gradlew.bat
unused.txt
/bin/

3.2. Initialize, add, submit, link to remote warehouse, push

Do the following in IDEA's console output
Insert picture description here

3.2.1 Initialization

  • Git init
  • Git status (check that the file is initialized successfully)

3.2.2 Add files to the warehouse

  • git config —global core.autocrlf false
  • Git add .

3.2.3 Submit

  • Git commit -am “first init”

3.2.4 Link to remote warehouse

  • Git remote add origin git warehouse address link to remote warehouse

For example:
git remote add origin https://gitee.com/kate-chan/easybuy-02.git

3.2.5 Push local warehouse content to remote warehouse

  • Git push -u origin master (out of date) push remote warehouse
  • Git pull
  • Git push -u origin master (still report an error)
  • Git push -u -f origin master force push
  • Git branch
    Master
  • Git branch -r
    Origin/master

3.2.6 Create your own development feature branch (feature)

  • Git checkout -b f-comment origin/master Create a branch on origin/master
  • Git branch
    Master
    –> f-comment
  • Git push origin HEAD -u push branch to remote warehouse

Finally, we can continuously deploy our project on our gitee

Guess you like

Origin blog.csdn.net/m0_50217781/article/details/112392552