In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly talks about "what are the advanced uses of Git". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the advanced uses of Git"?
Navigation-skip to previous branch git checkout-View history # each commit shows git log on one line-oneline# searches all commit logs for git log containing "homepage"-- all-- grep='homepage'# to get someone's submission log git log-- author= "Maxence" oops: previously reset a commit you didn't want to keep, but now you want to roll back? # get all operation history git reflog# and reset to the corresponding submission git reset HEAD@ {4} # …... Or. Git reset-- hard ouch: I've made a mess of the local warehouse. How should I clean it up? Git fetch origingit checkout mastergit reset-hard origin/master view the different git diff master..my-branch customizations of my branch and master # edit the last commit git commit-- amend-m "better commit log" # attach something to the last commit and keep the commit log unchanged git add. & & git commit-- amend-- no-edit# empty submission-- can be used to re-trigger CI to build git commit-- allow-empty-m "chore: re-trigger build"
Squash submission
For example, I want the last three rebase submissions:
-git rebase-I HEAD~3
-keep the pick of the first line, and replace the remaining submissions with squash or s
-Clean up the submission log and save it (type: wq in the vi editor)
Pick 64d26a1 feat: add index.jss 45f0259 fix: update index.jss 8b15b0a fix: typo in index.js correction
For example, I want to add something to the submission of fed14a4c.
Git submit Branch
Git add .git commit-- fixup HEAD~1# or you can replace HEAD~1git rebase-I HEAD~3-- autosquash# with the submitted hash value (fed14a4c). Execute the command on each submission when you save and exit the file (enter `: wq` in VI) rebase
If there are many features, there may be multiple commits in a branch. If the test fails, you want to find the commit that caused the test to fail. At this point you can use the rebase-- exec command to execute the command on each submission.
# run the `npm test` command git rebase HEAD~3-- exec "npm test" on the last 3 submissions
Temporary storage
Temporary storage is not just git stash and git stash pop;)
# Save all files being tracked git stash save "log information" # list all temporary entries git stash list# get and delete temporary items git stash apply stash@ {1} git stash drop stash@ {1} #... Or use a command. Git stash pop stash@ {1} cleanup # remove branches that do not exist on the remote warehouse git fetch-p # remove all branches containing `greenkeeper` git fetch-p & & git branch-- remote | fgrep greenkeeper | sed's / ^.\ {9\} / /'| xargs git push origin-- deleteGitHub = Git + Hub
I use Hub as an encapsulation of git. If you want to do the same, you can set up an alias: alias git='hub'
# Open a browser to access the repository url (GitHub warehouse only) git browse
Bonus: my favorite git alias
Alias g='git'alias glog='git log-- oneline-- decorate-- graph'alias gst='git status'alias gp='git push'alias ga='git add'alias gc='git commit-vault # alias yolo='git push-- force'# will report work every week using git-standup () {AUTHOR=$ {AUTHOR:= "`git config user.name`"} since=yesterday if [[$(date +% u) = = 1]] Then since= "2 days ago" fi git log-all-since "$since"-oneline-author= "$AUTHOR"}
At this point, I believe you have a deeper understanding of "what are the advanced uses of Git"? you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.