当前位置:网站首页>Experience the good team collaborative development process brought by Huawei cloud code hosting from 0 [my Huawei cloud experience journey] [play with Huawei cloud]
Experience the good team collaborative development process brought by Huawei cloud code hosting from 0 [my Huawei cloud experience journey] [play with Huawei cloud]
2022-06-12 03:25:00 【Hua Weiyun】
This experience is mainly about creating a cloud code warehouse in person , And carry out reasonable collaborative development , And end-to-end traceability , This function is used in enterprise project management , Research and development DevOps Play an important role in , From code change to software deployment , So the whole process can be traced . Finally, it introduces the important characteristics of service and the thinking of actual experience .
COdeHub Project address : https://devcloud.cn-north-4.huaweicloud.com/codehub/home
appetizer - be familiar with Git
First, the basics are Git This distributed control system should be understood clearly , Distributed means that there is no central server , Everyone's computer is a complete version library , such , You don't need to be connected to the Internet at work , Because the versions are stored on your own computer . Since everyone's computer has a complete version Library , How do many people work together ? For example, I changed the files on my computer A, Other people also changed the files on the computer A, At this time , You two just need to push each other's changes , You can see each other's changes .
A common noun
edition : Of course, the version manager should have a version , V1.0.0, V1.0.1 wait , Each version has its own unique name , It's a 40 Bit long hash value ;
Branch : Branch branch It's something that puts a series of versions together . There are multiple on a branch ( perhaps 1 individual ) edition , The main branch is called master, It is also the default branch , It represents the development process of the version ; A branch is a collection of versions .
HEAD: It's a pointer , Represents the git Version in use ( Not branch ), git You can only look at one version at a time ;
Remote warehouse : git It's not just Only locally , perhaps Only remotely Use . Warehouse remote origin It is the place where we can store the versions we have made together .
Git Structure
git Version control is performed through 4 Part of the system : work area , Temporary storage area , Warehouse , Remote warehouse ;
Workspace: work area
Is the directory that can be seen on the computer , such as c:/Code A folder is a workspace , every last git All workspaces have one .git Folder , It contains version information :
Index / Stage: Temporary storage area
It is used to store the version that has just been modified and has not been uploaded , It is also local . adopt git add . To add all files in all workspaces to the staging area
Repository: Warehouse area ( Or local warehouse / Version Library )
In the work area , for example c:/Code There's a hidden Directory .git This is not a work area , It is the version Library of the workspace (Repository). adopt git commit -m "message" To submit the version ;
Remote: Remote warehouse
It is the place where the transportation code is stored , Equivalent to a backup of your workspace , for example github, gitlab. adopt git push Submit to remote repository
Basic usage
The following four commands are in the working directory 、 staging directory ( It's also called index ) Copy files from warehouse to warehouse , Look at the picture below to understand .
- git add files Put the current file in the staging area .
- git commit Create a snapshot of the staging area and submit .
- git reset – files Used to undo the last git add files, You can also use it git reset Undo all staging area files .
- git checkout – files Copy files from the staging area to the working directory , Used to discard local changes .

You can use it. git reset -p, git checkout -p, or git add -p Go into interactive mode .
You can also skip the temporary storage area and directly retrieve files from the warehouse or submit code .

- git commit -a Equivalent to operation git add Add all the files in the current directory to the temporary storage area, and then run .git commit.
- git commit files Make a commit that includes the last commit plus a snapshot of the files in the working directory . And the file is added to the staging area .
- git checkout HEAD – files Roll back to copy last commit .
Appointment
Use pictures in the following form .

Green 5 Bit characters for submitted ID, Point to parent node respectively . The branches are shown in orange , Point to specific submissions separately . The current branch is attached by the HEAD identification . This picture shows the last 5 Submission ,ed489 Is the latest submission . master Branch to this commit , the other one maint Branch to grandfather commit node .
Illustrate common commands
Diff
There are many ways to see changes between commits . Here are some examples .

Commit
When submitting ,git Create a new commit with the files in the staging area , And set the node at this time as the parent node . Then point the current branch to the new commit node . The following figure , The current branch is master. Before running the command ,master Point to ed489, After submission ,master Point to new node f0cec And ed489 As parent node .

Even if the current branch is a submitted grandparent node ,git Will do the same . The following figure , stay master Grandfather node of branch maint Branch to commit once , Generated 1800b. such ,maint Branches are no longer master Grandfather node of branch . Now merge ( Or derivative ) Is a must .

If you want to change a commit , Use git commit --amend.git A new commit is made using the same parent node as the current commit , Old submission will be cancelled .

Another example is separation HEAD Submit , Later on .
Checkout
checkout Command to submit from history ( Or staging area ) Copy files to working directory , Can also be used to switch branches .
When a file name is given ( Or open -p Options , Or filename and -p Option on at the same time ) when ,git Copies files from the specified commit to the staging area and working directory . such as ,git checkout HEAD~ foo.c Node will be submitted HEAD~( The parent node of the current submission node ) Medium foo.c Copy to the working directory and add to the staging area .( If a commit node is not specified in the command , Copy the content from the staging area .) Note that the current branch will not change .

When no filename is specified , But give a ( Local ) When branching , that HEAD The identity will move to that branch ( in other words , We " Switch " To that branch ), Then the contents of the staging area and working directory will interact with HEAD The corresponding submission nodes are consistent . New submission node ( Image below a47c3) All files in will be copied ( To the staging area and working directory ); Only exists in the old submission node (ed489) Files in will be deleted ; Files that do not belong to both will be ignored , Unaffected .

If no filename is specified , No branch name specified , It's a label 、 Remote branch 、SHA-1 Value or something like master~3 Something similar , You get an anonymous branch , Referred to as detached HEAD( Separated HEAD identification ). This makes it easy to switch between historical versions . For example, you want to compile 1.6.6.1 Version of git, You can run git checkout v1.6.6.1( This is a label , Not branch name ), compile , install , Then switch back to the other branch , for instance git checkout master. However , When the submit operation involves " The separation of HEAD" when , Their behavior will be slightly different , See below for details .

HEAD Identify the commit operation in the detached state
When HEAD In a detached state ( Not attached to any branch ) when , Submit operation can proceed normally , But no named branches will be updated .( You can think of this as updating an anonymous branch .)

Once you switch to another branch , for instance master, Then this submission node ( Probably ) No more references to , And then it's discarded . Note that there will be no reference after this command 2eecb.

however , If you want to save this state , You can use the command git checkout -b name To create a new branch .

Compared with centralized version control system , The security of distributed version control system is much higher , Because everyone has a complete version Library in their computer , It doesn't matter if someone's computer breaks down , Just copy one from someone else . If there is a problem with the central server of the centralized version control system , No one can work .
In the actual use of distributed version control system , In fact, it is rare to push the revision of version library between two people's computers , Because maybe you two are not in the same LAN , Two computers can't access each other , Maybe your colleague is ill today , His computer didn't turn on at all . therefore , A distributed version control system usually has one as well “ Central server ” Our computer , But this server is only for convenience “ In exchange for ” Everyone's modification , Without it, everyone would work as well , It's just that it's not convenient to exchange changes .

Of course ,Git The advantage is not just that you don't have to connect to the Internet , We'll see later Git Extremely powerful branch management , hold SVN And so far behind .
CVS As the earliest open source and free centralized version control system , Until now, there are many people using it . because CVS Problems of self design , Will result in incomplete submissions , Inexplicably damaged version Library . It's also open source and free SVN Fixed a CVS Some stability problems of , Is the most widely used centralized version library control system .
Apart from free , There's a centralized version control system for charging , such as IBM Of ClearCase( It used to be Rational The company's , By IBM Acquired ), The characteristic is the installation ratio Windows Also big , It's slower than a snail , It works ClearCase It's the world 500 strong , They have a common feature that they are rich and powerful , Or people are stupid and have more money .
Cloud code warehouse service
Now we know the foundation of distributed version control system , Include the nouns involved ,git What is its process structure , It also includes the principle of its various commands , Finally, what are the benefits of the distributed version system for our code hosting , These are all important prerequisite knowledge points for learning Huawei cloud code hosting services . Then we started to create a cloud code warehouse , Experience all functions completely .
Go to the official website first, and locate development - Operation and maintenance , Select click code hosting CodeHub
Enter the console and select code hosting 
If you are a little white dot, start quickly , In this way, the whole process will be relatively simple , Let's click on the blue common creation at the back , If you want to gihub Warehouse import of is OK

After that, go to normal creation , Select and fill in the project name , Warehouse name and description , The system will automatically check the code retrieval service , Then you have to choose whether to configure .gitignore, Whether you want to open source or not depends on you

The following figure shows the successful creation , There are four options after clicking , Let's choose warehouse settings .

Look at this and what we use every day github What's the difference , Also don't say , Yes IP White list , Remote backup and risk operation , Submit these to the network github They all have no functions .

Let's go back to the project settings , This function has permission management , Service menu management , Service extension point management and host group management ; I believe you can understand it literally , I just re introduced myself .

Let's move on to the warehouse setup , I wonder if you have seen the setting of locking the warehouse , The purpose is to prevent anyone from destroying the code warehouse of the upcoming release , The administrator can lock the warehouse .
After locking the warehouse , No one can submit code to any branch ( Including the administrator himself ). Under normal circumstances, do not move .

Back to the warehouse file, you can view your own files online , Editors can also go back and delete .

And you can create a new file directory to the warehouse , Create new sub modes and important upload files , If these are in github You can't do it , This is very detailed .

Now we are master Create... Under the branch test.java after , We can look at history , Then modify the traceability , And compare the code , These are usually in git Command to operate

Then we create branches in the warehouse , Make a merge request , This means selecting two branches to view changes or start a new request . Merging is allowed only if the contents of two branches are different .

Pay attention to your target branch , It is reasonable to choose the merging person and reviewer, which is very convenient for such project management , And you can specifically associate a work item .

If you don't know the business process of the code , You can see the code review record , Including your submission and merge request .

Let's take a look at related work items, which are very useful functions in enterprise development , The method is that the user needs to submit the code , Enter the work item number , To realize the bidirectional association between work items and code . The format of the information entered when submitting the code is “fix # Work item number The annotation information submitted this time ”.

If your code has been developed by your development team , You can now select the new compile build task for the file .
Of course, building is not that simple , Need tools to build , Then set the command ,setting The configuration release depends on the package. Finally, the unit test , These are commonly used in Github There is no such thing .

We are still in the warehouse except for code hosting , There is also a unique function of code checking , Set quality access control , Check time , And the practical functions of generating new problems .

If it is a problem, the boiler can be set , For problem level , State or time other means to filter .

Another important thing is warehouse statistics , You can view the total number of submissions , Submission frequency , And the number and time of submission , It is very practical for project maintainers .

So for the warehouse , You can make a very detailed introduction , For example, the initial graph , How much capacity did you use first , How many branches are there , The last statistical time is displayed .

Finally, the remote backup in the setting is a very important choice in some emergency situations , You can back up your projects to ECS servers in other regions , This ensures the normal operation of the service , It can also be used. git Manually complete the local backup , Isn't it very sweet .
Finally, the setting of warehouse IP White list , First, find out what it means .IP The white list is right IP The white list of the scope , By setting IP The white list can greatly enhance the security of your warehouse ; Only in IP Warehouse access within the white list is allowed , Other than that IP All access initiated is denied . This is the simplest one IP White list format , For example, put your personal home computer IP Add to whitelist , such as :117.78.39.149.

It involves CIDR Format , Also known as classless encounter routing, you need to understand it 
That is, when your server is in a LAN and using CIDR When routing , In this case, you can specify the local area network 32 Bit exit IP And a number of bits that specify the network prefix ; such , From the same IP Requests initiated , As long as the network prefix is the same as the prefix you set , Can be regarded as coming from the same credit scope and accepted ; give an example : such as 222.80.18.18/25, So even in the same IP The server of others under the LAN ( The number of network prefix digits is not the first 25 position ) Can still be intercepted .
summary
Cloud code hosting service is the development trend of distributed version control system , It is also close to business development , To improve the efficiency of development among team members , There are many useful features waiting for you to explore more new features . I also learned a lot of useful things , For example, this code check , Remote backup , also ip The white list is very useful in the actual production environment , It's good to pay attention .
边栏推荐
- Comparison of scores
- tcp 三次握手与四次挥手
- 微信小程序项目实例——双人五子棋
- What is the commonly heard sub table of MySQL? Why does MySQL need tables?
- [DFS "want" or "don't"] seek subsets; Seeking combination
- In 2022, don't you know the difference between arrow function and ordinary function?
- Evolution and practice of Unicom real-time computing platform
- 微服务概念及介绍
- 微信小程序项目实例——体质计算器
- Restful interface design specification [for reference only]
猜你喜欢

Comparaison de la taille des fractions

分數大小的比較

What is the core of Web3?

Comparison of scores

Three ways for ORALCE to process column to row conversion and finally generate table style data

2020-12-10

2020-12-06

Youcans' opencv lesson - 10 Image restoration and reconstruction

MySQL的check约束数字问题

Demand and business model innovation - demand 10- observation and document review
随机推荐
MySQL partition table create delete modify view
微信小程序项目实例——体质计算器
字符串处理:
Restful interface design specification [for reference only]
What is a request response pair called? [repeat] - what is a request response pair called? [duplicate]
Oracle users and tablespaces
[point cloud compression] variable image compression with a scale hyperprior
[Business Research Report] Research Report on super automation technology and application (2022) -- download link attached
Hudi of data Lake (14): basic concepts of Apache Hudi
Final summary of addition, deletion, modification and query - 2.1 (single table - addition, deletion, modification and query)
The road of global evolution of vivo global mall -- multilingual solution
[Business Research Report] forward looking report on urban renewal and development in China in 2021 - download link attached
Comparaison de la taille des fractions
Domestic mobile phones are snubbing low-end consumers, and Nokia provides them with high-quality products
What is the commonly heard sub table of MySQL? Why does MySQL need tables?
TCP three handshakes and four waves
Go 语法 变量
2020-12-07
Sequence list and linked list ----- advanced
In 2022, why is there a market for Shanzhai products?