当前位置:网站首页>[PROJECT] small hat takeout (8)
[PROJECT] small hat takeout (8)
2022-04-23 16:57:00 【Lemon hat】
Small hat takeout
Chapter viii. Git
One 、 What is? Git ?
- Git Is a distributed version control tool , It is mainly used to manage the source code files in the development process (Java class 、xml file 、html Page etc. ), It is widely used in the process of software development .
Two 、Git Can do ?
- Code backtracking
- Version switch
- Multiplayer collaboration
- Remote backup
3、 ... and 、Git summary
- Git brief introduction
- Git Is a distributed version control tool , It is usually used to manage the source code files in the process of software development . adopt Git Warehouse to store and manage these files ,Git There are two kinds of warehouses :
- Local repository : Developers on their own computers Git Warehouse
- Remote warehouse : On the remote server Git Warehouse
- commit: Submit , Save the local file and version information to the local warehouse
- push: push , Upload the local warehouse file and version information to the remote warehouse
- pull: Pull , Download the remote warehouse file and version information to the local warehouse
- Git Is a distributed version control tool , It is usually used to manage the source code files in the process of software development . adopt Git Warehouse to store and manage these files ,Git There are two kinds of warehouses :
Four 、Git Code hosting services
1. frequently-used Git Code hosting services
- Git There are two types of warehouses in , That is, local warehouse and remote warehouse . So how do we build Git Remote warehouse ?
- We can use some code hosting services provided on the Internet to realize , One of the more common ones is GitHub、 Code cloud 、GitLab etc. .
- GitHub, Is a hosted platform for open source and proprietary software projects , Because it only supports Git Hosted as a unique library format , So the name GitHub
- Code cloud , It is a domestic code hosting platform , Because the server is in China , So compared to GitHub, The code cloud will be faster
- GitLab, Is an open source project for warehouse management system , Use Git As a code management tool , And built on this basis web service
- BitBucket, Is a source code hosting site , use Mercurial and Git As a distributed version control system , At the same time provide business plan and free account
2. Use code cloud code hosting service
- The operation flow of using code cloud is as follows :
- Sign up for a cloud account
- Login code cloud
- Creating a remote repository
- Invite other users to become warehouse members
2.1 Creating a remote repository
- After creation, you can view the warehouse information
- Every Git The remote warehouse will correspond to a network address , Click on 【 clone / download 】 Button , Click... In the pop-up window 【 Copy 】 Button to get the network address
2.2. Invite other users to become warehouse members
- You have already created your own remote warehouse on the code cloud , At present, the warehouse member is only himself ( As Administrator ). In the actual development of enterprises , A project is often developed by multiple people , In order to allow multiple participants to operate the remote warehouse , You need to invite other project participants to be called members of the current warehouse .
5、 ... and 、Git Common commands
1. Git Global settings
- When installed Git The first thing to do after is to set the user name and email Address . This is very important , Because every time Git All submissions will use this user information .
- stay Git Execute the following command from the command line :
- Set user information
- git config --global user.name “lemon”
- git config --global user.email “[email protected]”
- View configuration information
- git config --list
- Set user information
- Be careful : Above set user.name and user.email It's not the user name and email address we use when registering code cloud account , You can set any number here .
2. obtain Git Warehouse
- To use Git Version control our code , First you need to get Git Warehouse
- obtain Git Warehouses usually have two ways :
- Initialize a... Locally Git Warehouse ( Not commonly used )
- Clone from remote warehouse ( Commonly used )
2.1 Initialize locally Git Warehouse
- The steps are as follows :
- Create an empty directory in any directory ( for example repo1) As our local Git Warehouse
- Go into this directory , Right click to open Git bash window
- Carry out orders git init
- If you see... In the current directory .git Folder ( This folder is a hidden folder ) shows Git Warehouse created successfully
2.2 Clone from remote warehouse
- Can pass Git The command provided is cloned from the remote warehouse , Clone remote warehouse to local
- Order form :git clone【 long-range Git Warehouse address 】
3. work area 、 Temporary storage area 、 Version Library Concept
- Version Library : What I saw in front .git The hidden folder is the version library , A lot of configuration information is stored in the repository 、 Log information and file version information
- work area : contain .git The directory of the folder is the workspace , Also known as working directory , It is mainly used to store development code
- Temporary storage area :.git There are a lot of files in the folder , One of them index The file is the staging area , It can also be called stage. A staging area is a place to temporarily save modified files
4. Git The status of the files in the workspace
- Git There are two states for files in the workspace :
- untracked No trace ( Not under version control )
- tracked Tracked ( Be included in version control )
- Unmodified Unmodified state
- Modified Status modified
- Staged Staging state
- The status of these files will follow us Git Your command has changed
5. Local warehouse operation
- The common commands of local warehouse are as follows :
- git status View file status
- git add Add the modification of the file to the temporary storage area
- git reset Cancel the staging of files in the staging area or switch to the specified version
- git commit Submit the file modification of the staging area to the version Library
- git log Check the log
6. Remote warehouse operation
- git remote View remote repository
- git remote add Add remote repository
- git clone Clone from remote warehouse
- git pull Pull... From a remote warehouse
- git push Push to remote warehouse
6.1 View remote repository
- If you want to view the configured remote warehouse server , Can run git remote command , It will list the abbreviations of each remote server .
- If you have cloned a remote warehouse , So at least we should be able to see origin, This is a Git The default name of the cloned warehouse server .
6.2 Add remote repository
- Add remote repository , function git remote add <shortname> <url> Add a new remote Git Warehouse , Also specify an abbreviation that can be referenced .
6.3 Clone the remote repository locally
- If you want to get an existing Git Copy of remote warehouse , This is the time to use git clone command .Git The clone is the Git Almost all data on the warehouse server ( Including log information 、 History, etc ), Not just copying files needed for work .
- The command format of clone warehouse is :git clone [url]
6.4 Push to remote warehouse
- Push local warehouse content to remote warehouse , You can use commands :git push[remote-name][branch-name]
- In the use of git push When the command pushes the local file to the code cloud remote warehouse , Identity authentication is required , Only after passing the authentication can you push , as follows :
6.5 Pull... From a remote warehouse
- git pull The function of the command is to obtain the latest version from the remote warehouse and merge it into the local warehouse , Command format :git pull [short-name][branch name]
- If the current local warehouse is not cloned from a remote warehouse , It's a locally created warehouse , And there are files in the warehouse , At this time, an error will be reported when pulling files from the remote warehouse (fatal:refusing to merge unrelated histories)
- This problem can be solved in git pull Add parameters after the command --allow-unrelated-histories
7. Branch operation
- Branch is Git Very important concepts in the use process . Using branching means that you can separate your work from the main development line , So as not to affect the main line of development .
- The same warehouse can have multiple branches , Each branch is independent of each other , Mutual interference .
- adopt git init A local warehouse is created by default when the command creates a local warehouse master Branch .
- Relevant command :
- git branch View branches
- git branch[name] Create a branch
- git checkout[name] Switch branches
- git push [shortName][name] Push to remote warehouse Branch
- git merge [name] Merging branches
7.1 View branches
- git branch List all local branches
- git branch -r List all remote branches
- git branch -a List all local and remote branches
7.2 Create a branch
- Create branch command format :git branch [name]
7.3 Switch branches
- Switch branch command format :git checkout [name]
7.4 Push to remote warehouse Branch
- Push to remote warehouse branch command format :git push [shortName] [name]
7.5 Merging branches
- Merge branch command format :git merge [name]
8. Label operation
- GIt The label in , It refers to the state of a branch at a specific point in time . Through the label , It's very convenient to switch to the state of marking .
- What's more representative is that people will use this function to mark publishing nodes (v1.0、v1.2 etc. ). Here is mybatis-plus The label of :
- Relevant command :
- git tag List existing tags
- git tag [name] Create a label
- git push [shortName][name] Push labels to remote warehouse
- git checkout -b [branch][name] Check out the label
8.1 List existing tags
- List the existing tags. You can use the command :git tag
8.2 Create a label
- To create a label, you can use the command :git tag [name]
8.3 Push labels to remote warehouse
- The format of the command to push the tag to the remote warehouse :git push [shortName] [name]
8.4 Check out the label
- When checking out a label, you need to create a new branch to point to a label , Check out the command format of the label :git checkout -b [branch] [name]
6、 ... and 、 stay IDEA Use in Git
1. stay IDEA Middle configuration Git
- stay IDEA Use in Git, In essence, it is installed locally Git Software , So you need to be in IDEA Middle configuration Git.
2. obtain Git Warehouse
- stay IDEA Use in Git There are two ways to get the warehouse :
- Initialize the warehouse locally
- Clone from remote warehouse
3. Local warehouse operation
- Add the file to the staging area ( Right click the file Git -> +Add)
- Submit files from staging area to version Library ( Right click the file Git -> Commit Directory)
- Check the log
4. Remote warehouse operation
- View remote repository
- Add remote repository
- Push to remote warehouse
- Pull... From a remote warehouse
5. Branch operation
-
View branches
-
Create a branch
-
Switch branches
-
Push the branch to the remote warehouse
-
Merging branches
版权声明
本文为[Lemon hat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231337148458.html
边栏推荐
- Website_ Collection
- 自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
- ACL 2022 | dialogved: a pre trained implicit variable encoding decoding model for dialogue reply generation
- oracle 中快速获取表的列名列表
- Change the password after installing MySQL in Linux
- feign报400处理
- Paging the list collection
- Milvus 2.0 質量保障系統詳解
- 蓝桥杯省一之路06——第十二届省赛真题第二场
- Go language RPC communication
猜你喜欢
Detailed explanation of file operation (2)
Zhongang Mining: Fluorite Flotation Process
PyTorch:train模式与eval模式的那些坑
Deepinv20 installation MariaDB
Feign report 400 processing
CentOS MySQL multi instance deployment
1959年高考数学真题
Milvus 2.0 質量保障系統詳解
[pimf] openharmony paper Club - what is the experience of wandering in ACM survey
MySQL master-slave replication
随机推荐
MySQL restores data through binlog file
关于局域网如何组建介绍
MySql主从复制
博士申请 | 厦门大学信息学院郭诗辉老师团队招收全奖博士/博后/实习生
Change the password after installing MySQL in Linux
ACL 2022 | DialogVED:用于对话回复生成的预训练隐变量编码-解码模型
PHP efficiently reads large files and processes data
STM32__ 03 - beginner timer
Multithreaded @ async thread pool
面试百分百问到的进程,你究竟了解多少
Encapsulating the logging module
Execution plan calculation for different time types
Installation and management procedures
TypeError: set_figure_params() got an unexpected keyword argument ‘figsize‘
Detailed explanation of Milvus 2.0 quality assurance system
Get the column name list of the table quickly in Oracle
How to build tiktok user trust and drive fan growth
Mock test using postman
PyMySQL
JSON deserialize anonymous array / object