In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of Git function, the article is very detailed, has a certain reference value, interested friends must read it!
I. The code just submitted needs to be fine-tuned.
Just recently submitted a piece of code, and then said to the front end, the interface is good. After 2 minutes, the front end said to you, hey, brother, can that amount be returned to an integer, not a decimal point?
At this time, we usually modify it and submit a version. Well, after another two minutes, the front end came again and said, hey, brother, can the date be formatted differently...
Normally we will modify and then submit a version, so just some simple changes, we submitted several versions, can be OK, but there is a more elegant and simple solution: commit --amend
"Amend" means "correct." When committing, if you add the--amend parameter, Git doesn't add a commit to the current commit, but instead merges the contents of the current commit with the contents of the staging area to create a new commit, replacing the current commit with the new commit. So what commit --amend does is what it literally means: it corrects the latest commit.
Specifically, when you have made the changes, run directly:
git add .git commit --amend
Then you will see the message you submitted earlier:
You can modify it or keep it, and then save it to exit. Your latest commit has been updated, as shown below:
2. What needs to be modified is not the latest commit, but the penultimate one.
All of a sudden we have to make some minor adjustments to our penultimate submission, so we can't use the above method at this time, but there are ways.
Rebase -i: Short for rebase --interactive, meaning "interactive rebase."
After git log we find that it is the penultimate commit that needs to be modified, so at this point we can run:
git rebase -i HEAD^^, this screen will pop up.
At the top of the edit screen is a list of all the commits that will be "rebased," i.e. the penultimate commit "modify testgit" and the latest commit "mofify .gitignore." Note that this arrangement is in positive order, with the old commit at the top and the new one at the bottom.
At this point, we need to modify which commit, we can change the pick before the commit to edit, and then we can exit the interface.
The above interface tells us that the rebase process has stopped at the commit that needs to be modified, and then we can modify it. After modification:
git add .git commit --amend
After uploading the modification, you can run:
git rebase --continue
If there is no conflict, then the rebase is perfect.
Emergency: Stash Storage
When you are typing the keyboard, immersed in developing a new feature, suddenly someone came to you and said, hey, brother, you developed a bug in that feature before, quickly change it, at this time your new branch function has just started, if you commit directly once is definitely OK, but there is a better way to deal with it- git stash .
Git stash will empty your work directory of changes and store them in another place. Note that git stash ignores files that are not tracked, so you need to add the parameter-u, i.e. git stash -u.
After you fix the bug, switch back to the working branch. Then:
git stash pop The above is "Git function example analysis" All the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
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.