Often times when you noticed something has changed / break / less optimised, yet you do not know when this change was introduced into your repository. This is a useful command that I am looking forward to use it. This is especially useful when you have reset -hard or rebase, you can still find back the commit reference that you were at previously, so you can recover them. The reference log shows you all the HEAD position you have been to. This is especially useful when you have merged of branches in, -first-parent allow you to filter out only the merge commit and the commit you have made on the current branch. You can follow only the first parent commit upon seeing a merge commit. A simple merge commit has 2 parent, so -merge is equivalent to -min-parents=2. You can specify commits with the number of parents. grep is a OR filter, -all-match make it a AND filter -min-parents, -max-parents, -merges, -no-merges You can filter out commits that does not match the -grep -all-match You can filter out commits based on commit message -invert-grep You can filter out commits within a specific timeframe -grep There's a few options that is worth mentioning, that allow us to search through the sea of commits: -since, -after, -until, -before The go-to command to look at your git history. In the companies that I have worked with, forbidden a rebase on a common branch, especially the master branch. If unfortunately, at the same time, y has made more commits to his local branch, he would have to git rebase the new changes onto the remote branch, or git cherry-pick the new changes after the git reset -hard. So, the correct way, if the rebase is necessary, is to notify y about the rebase, so that y can git reset -hard his branch to the remote branch. In most cases, there would be a merge conflict, because x and y's branch would have made changes on the same file. While y on the other hand, did not know about the rebase, so when y pulled the code, it ended up with a messed up merged of a messed up git history: ( Note: You can push without -force if the origin branch cannot fast-forward merge your local branch) To make the change on the remote server as well, x forced push his branch to the remote server. Because the rebase on his local machine changed the git history on his local copy only. While x had done that, that was just a part of the whole picture. X decided to rebase the feat/a branch to squash and drop some commits: Say x and y are working on the feat/a branch. Git pull -rebase git rebase a shared branch There's 2 kind of git merge, the fast-forward and non fast-forward. So, we can look for it whenever we need it. I hoped that, with it, we are aware of what is available in our toolbox. In this talk, I listed out all the common history manipulation commands Git provides. I do google or refer to the docs whenever I am unsure of the commands. I am by no means a Git master or anywhere near mastering Git. Will there be a "Git Guddest"? □ Disclaimer The title of the talk was called "Git Gudder", because almost a year ago I did a lightning sharing on "Git Gud", (Get Good), this follow up sharing used the comparative of "Git Gud", therefore, "Git Gudder". This week in React Knowledgeable, I did a sharing on Git commands. -min-parents, -max-parents, -merges, -no-merges.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |