1.git stash combing 1.1git stash cloning and synchronization
First, the logic of stash git is this.
When a new change is made locally, when the current version is not present at the time of submission, it is necessary to pull the latest version of develop in your own code warehouse.
In the Git stash setting if automatic synchronization is set, then the code warehouse of their own code warehouse and the general library will be synchronized at any time, then pull their own develop will be the latest version
1.2 Practices for Server version updates
After pulling down you can choose whether to use Git rebase to reach fast forward or use git merge directly
The official (LI) side (Yu) said it was not possible to use merge directly, preferably using rebase, because if you use merge directly, you will merge your new features with the latest version into a new version. The use of rebase is to first pull down the latest version, and the changes in their new features to edit in the latest version, so when re-submit, our new changes are a separate version of the version rather than the combination of the version produced.
1.3 Compare log graphs to draw conclusions
Look at the log diagram for more intuitive results.
Recent code is maintained by us can see the log diagram as follows
Each version is self-contained, with a clear structure
In the case of a previous engineer using merge during maintenance, the log is ambiguous and difficult to understand as follows
Before looking forward to the previous MoMA project log more confusing
So the future practice is to use rebase to achieve the fast-forward effect of the practice.
2.git Squash Technology
When using git as a source code manager, you need to commit the changes you make every now and then, so that you can query them. The job is to suggest a little bit of minor changes in the commit, because the more carefully submitted to see the more clearly. But when you submit your own code repository with many details to the server to build a pull request, it is sometimes necessary to combine trivial multiple commits to form a complete commit of this requirement. Then you need to use git squash to sort through the compressed message.
When I modify four files and each step is submitted separately, my project git log is displayed as follows:
If each commit is established PR and submitted to the main code warehouse, the main library will be modified version of the very many, for the future maintenance also increased the difficulty. If you use git squash technology, you can assemble multiple logs together. The following full PR operation steps can be seen in 2-7 steps for specific code operations.
3. Full PR operation Step (12 Steps)
1.git Remote-v First look under Origin to avoid errors
2.git Checkout Changebadcode Switch to your project branch first
3.git Log View the log and determine how many logs need to be merged
4.git Rebase-i Head~6 bring together six versions of the top to go to the edit page
5. Change the pick in front of the log to be compressed to s (squash abbreviation)
It is important to note that you must keep a pick, and if you change all the pick to s then there will be no merging vectors and the following error is reported.
You can only go to the next step by using Git rebase--continue to continue editing or Git rebase--abort cancel this operation to resolve the issue.
6. (The previous operation is correct) input: Wq Save and exit the Change Message page appears
7. Use the VIM directive to delete the space line between each message and enter: Wq
The end result is this
8. To get the latest version of develop, you must first switch to develop--------git checkout develop
9. Git pull origin develop get the latest develop version
10. You need to switch to your own branch before develop can be rebase-----git checkout Newfix
git rebase develop put your newly developed features into the latest version
12. You need to switch to the trunk before you can merge your branches------git checkout Develop
Git merge Newfix It's time to merge.
Git push origin develop to its own Origin code repository
15. Create a pull request on the Web page to submit changes to the administrator
attach several common directives (continue to increase):
Git Branch View branches
Git reflog to see the changes to this project
git log--graph--oneline displays the first six-bit log code and the corresponding message
Git checkout-b newfix to create a new branch on the main branch.
git cherry-pick changebadcode copy old branch changes on new branch
git branch-d changebadcode Delete a branch. -D is Force delete
git Add. Add all the changes. (You can show a different diff with git status first) and add a single file
Git commit--amend for the commit just submitted, but does not generate log
Git stash correct steps to submit PR &git squash Technology