In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Git research and development application scenario is what, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Git was born in 2002, developed and improved by Linus Torvalds, the father of Linux, and his team. It adheres to the open source spirit of Linux and brings a great version control experience for the R & D team. The following is based on the working principle of Git, in-depth discussion of workflow and other issues in various R & D scenarios.
Git working mode
Code submission process
Once a modification is successfully submitted to the remote repository, it will go through four stages: 1 local workspace-> 2 cache area-> 3 version library-> 4 remote version library. By executing the corresponding Git command, the file jumps in these four areas and presents different states:
1. Modified (modified): including three types of files, new files, modified files, deleted files
two。 Staged: a git add or git rm operation is performed on a modified file and the file becomes temporarily stored and enters the temporary storage area. The temporary storage area is actually a file index directory tree, which records all the file name and file status information. it has been indexed to establish the corresponding relationship between the file name and the file content (saved in the object library .git / objects).
3. Submitted (committed): a git commit operation is performed on a temporarily stored file, and the file becomes submitted and enters the local version repository.
4. Uploaded: git push the submitted file, and the file becomes uploaded and enters the remote version repository.
How does Git record each submission
Let's think about it, how should the version control system record each submission? The normal mind must be to record the "delta", that is, the difference in the content of the file between the two versions, and it is true that most version control systems do this, such as the familiar CVS,SVN. However, Git does not! Each time you commit an update, Git takes a snapshot of all files and saves an index to that snapshot.
This preservation method brings a lot of benefits. When switching versions, you can directly reference the index pointing to the target version. There is no need for merge between versions like differential storage, which will be much faster. More importantly, it provides a prerequisite for lightweight branch switching mentioned later.
Git branch
The essence of a new branch of Git is to create a variable pointer to the last submission, so the creation of a Git branch is not a copy of the contents of the version library, but just a new pointer, which is saved in the file in the form of a 40-character SHA-1 string, which is unimaginably lightweight because of the version design concept of "snapshot" preservation.
Git workflow
What is a Git workflow? You can understand it as a branching strategy for code management. Starting from the typical GitFlow workflow, together with the code hosting platform I am using (Huawei Software Development Cloud), I will explain in detail how workflow serves project process management and team collaborative development.
·master: the mainline branch. The version is stable and can be deployed in a production environment. This branch can only be merged from other branches and cannot submit changes directly on this branch.
Create a new branch:
Enter the new branch name in the development cloud interface and choose which branch to check out from.
Angular develop: the main development branch, which is used to integrate and test the latest integrated development effort, including code to be released to the next Release.
Angular feature: feature branch, one for each feature, for developers to submit code and self-test. Once the development is complete, we merge back into the Develop branch and proceed to the next Release.
^ hotfix: patch branch, temporary branch created when a new Bug is discovered in the production environment. After problem verification, it is merged into the Master and Develop branches, so the changes to the Hotfix will move on to the next Release.
Angular release: release branch. When a new version is released, it is created based on the Develop branch, and when the release is complete, it is merged into the master and develop branches.
The relationship between the branches can be seen in the "warehouse network" of the development cloud:
Advantages: project management process is clear
Disadvantages: relatively complex, need to maintain two long-term branches at the same time, not suitable for website projects.
Branch merging
No matter which kind of workflow involves branch merging (integrating changes from one branch into the current branch), there are two main methods: tripartite merging (merge) and derivative merging (rebase). We experience the difference between the two merging methods by performing different operations on the same scene.
Scenario: C4 node has been added to the master branch and C3 node has been added to the hotfix branch. Now merge the hotfix branch into the master branch:
1. The three parties include the new hotfix node C3 Magi master new node C4 and their common ancestor node C2. This kind of merge operation is simple, but the new merge node C5 forms a ring, and the readability of the version record is poor.
A) PC command operation mode:
# git checkout master
# git merge hotfix
B) develop cloud platform page operations:
Step one:
Step 2:
two。 The derivative first saves the new node C4 of the master branch in the .git / rebase directory as a patch, then synchronizes the latest code of the hotfix branch, and then applies the patch C4'.
# git checkout master
# git rebase hotfix
Conflict resolution
Type 1: two merged branches modified the same line of code
Solution:
1. Analyze which modification method is correct and merge it manually
two。 Submit changes.
Type 2: the file is renamed to a different name
Solution:
1. Confirm which name is correct and delete the wrong one
two。 Submit changes.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.