Skip to content
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

Merged
merged 1 commit into from
May 26, 2016

Conversation

fanquake
Copy link
Member

Fixes #8032

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
Copy link
Member

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?

Copy link
Contributor

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`.

Copy link
Member

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.

Copy link
Member

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 

@maflcko
Copy link
Member

maflcko commented May 10, 2016

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.

@maflcko maflcko added the Docs label May 10, 2016
@laanwj
Copy link
Member

laanwj commented May 10, 2016

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
Copy link
Member

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.

@fanquake fanquake changed the title [doc][trivial] Add basic git squash workflow [doc][trivial] Add basic git squash workflow [skip ci] May 10, 2016
@laanwj
Copy link
Member

laanwj commented May 10, 2016

BTW: the [skip ci] did'n't work. I think you need to put it in the commit message, unfortunately.
(doesn't have to be in the first line though, luckily)

@maflcko
Copy link
Member

maflcko commented May 10, 2016

utACK 90963e5

@paveljanik
Copy link
Contributor

utACK 90963e5

@achow101
Copy link
Member

utACK 90963e5

@petertodd
Copy link
Contributor

utACK 90963e5

@paveljanik
Copy link
Contributor

This is ready for merge.

@arowser
Copy link
Contributor

arowser commented May 25, 2016

Can one of the admins verify this patch?

@laanwj laanwj merged commit 90963e5 into bitcoin:master May 26, 2016
laanwj added a commit that referenced this pull request May 26, 2016
90963e5 [doc] Add basic git squash example (fanquake)
@fanquake fanquake deleted the contrib-squash branch May 26, 2016 05:36
codablock pushed a commit to codablock/dash that referenced this pull request Dec 21, 2017
…p ci]

90963e5 [doc] Add basic git squash example (fanquake)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 'how to squash several fixup commits' to our coding guideline
8 participants