In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains the advanced usage of sharing git. The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the advanced usage of sharing git.
Navigation-skip to the previous branch
Git checkout-
View history
# each submission displays git log on one line-- oneline # search all submission logs for the submission git log containing "homepage"-- all-- grep='homepage' # to get someone's submission log git log-- author= "Maxence"
Oops: you reset a submission that you didn't want to keep, but now you want to roll back?
# get all operation history git reflog # reset to the corresponding submission git reset HEAD@ {4} #. Or. Git reset-hard
For details, see my other article, What's happens when you git commit.
Ouch: I've made a mess of the local warehouse. How should I clean it up?
Git fetch origin git checkout master git reset-hard origin/master
Check the difference between my branch and master
Git diff master..my-branch
Custom submission
# Edit the last submitted git commit-- amend-m "better commit log" # add something to the last commit and keep the submitted 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"
If you don't know how to write a commit log, take a look at my article that introduces the Angular-style submission log convention.
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.js s 45f0259 fix: update index.js s 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~1 git rebase-I HEAD~3-- autosquash # with the submitted hash value (fed14a4c) to save and exit the file (enter `: wq` in VI)
Execute commands on each submission during 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 entries git stash apply stash@ {1} git stash drop stash@ {1} #... Or use a command. Git stash pop stash@ {1}
Clear
# remove branches that do not exist on the remote repository git fetch-p # remove all branches containing `greenkeeper` git fetch-p & & git branch-- remote | fgrep greenkeeper | sed's / ^.\ {9\} / /'| xargs git push origin-- delete
GitHub = 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
For other commands, please refer to here.
Bonus: my favorite git alias
Alias alias glog='git log-- oneline-- decorate-- graph' alias gst='git status' alias gp='git push' alias ga='git add'alias gc='git commit-v'? Alias yolo='git push-- force' # will report work weekly 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"} Thank you for reading, the above is the content of "sharing git Advanced usage". After studying this article, I believe you have a deeper understanding of the problem of sharing git Advanced usage, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.