-
Notifications
You must be signed in to change notification settings - Fork 36.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[doc][trivial] Add basic git squash workflow [skip ci] #8034
Conversation
At this stage one should expect comments and review from other contributors. You can add more commits to your pull request by committing them locally and pushing to your fork until you have satisfied all feedback. If your pull request is accepted for merging, you may be asked by a maintainer to squash and or [rebase](https://git-scm.com/docs/git-rebase) your commits before it will be merged. The basic squashing workflow is shown below. | ||
|
||
git checkout your_branch_name | ||
git rebase -i commit_shasum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is commit_shasum
?
Maybe HEAD~n
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe git rebase -i HEAD~<amount of commits to squash>
Maybe add something like (please clean/rewrite the english)
Use `p` at the beginning of the line to indicate the commit you wish to use as the base commit
Use `s` at the beginning of the line for all commits you want to squash into the commit you have marked with `p`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git rebase -i HEAD~
It's not the number of commits to squash, but at least that amount +1, as you need a base commit too to squash into.
Usually more like the total number of commits in someone's PR that they want to edit.
I haven't found a really user friendly way to determine this base commit yet, which is why I usually look it up for people. HEAD~x may be best, but is also something to get wrong easily if you miscount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, git will tell me what the commands are when I am doing the rebase:
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
It might be worth to mention that squashing is not required when the commits each have a different "topic"/task and are not fixup commits. Also, it might come in handy to add section headings, so it is easier to link to a section... Concept ACK. |
Concept ACK, this was long overdue, somehow I was not lazy enough describe this again in every new contributor's pull, but too lazy to add it into here :) Thanks for doing so. |
git checkout your_branch_name | ||
git rebase -i commit_shasum | ||
# set commits from 'pick' to 'squash' | ||
# save and quit the editor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this, they'll get another editor in which they can combine/refine the commit messages.
BTW: the [skip ci] did'n't work. I think you need to put it in the commit message, unfortunately. |
utACK 90963e5 |
utACK 90963e5 |
utACK 90963e5 |
utACK 90963e5 |
This is ready for merge. |
Can one of the admins verify this patch? |
90963e5 [doc] Add basic git squash example (fanquake)
…p ci] 90963e5 [doc] Add basic git squash example (fanquake)
Fixes #8032