“This is the second day of my participation in the First Challenge 2022.
Problem introduction
In daily work, branch development is usually divided according to iteration function, i.e. one branch per iteration. Normal iterative development – test – live without problems. But suddenly there is a very urgent problem bug in the last branch, which needs to be modified and optimized. At this time, all the development is on the new branch, and branch switching is random, which is easy to lead to code confusion, which is not conducive to code management. Then is there a way to temporarily save the current code state? It is similar to playing a game when you are young and want to save, play something else or watch TV in the middle of the game.
Ii. Solutions
Procedure 1 Complete the operation using IDEA
1 In the new branch, click Version control VC-Git-Stash Changes
Fill in the current temporary storage status information to create a temporary warehouse
2 switch old branch, fix bug problem, submit
Switch to a new branch, find a temporary warehouse, and restore the code
Click VC-Git-Unstash Changes to restore the code and delete the temporary repository
2 Run the Git command to complete the operation
Use the following command:
- Git status Displays the current git status
- Git Stash Save ‘Current stash’
- Git Stash List View all temporary lists
- Git Stash pop restores the last temporary branch and removes the temporary repository
- Git Stash apply ID Recovery temporary branches are recovered by their IDS, which can be viewed in the list
Case study:
1 git status
2 Git Stash Save ‘2022- New branch ‘
3 git stash list
4 git stash apply 0
Three summary
In daily development, like other scenarios, these functions are still well used, and the use of code must be controlled. For code maintenance work, also met a lot of time, most of the problems are caused by operation in violation of stipulations, in addition to the use of Git, we also have to study hard to master, on the one hand, to learn the most basic Git command, on the one hand, also want to learn the latest tool in the function, help us to better and faster code.