-
Notifications
You must be signed in to change notification settings - Fork 10k
Squashing Commits
Yury Delendik edited this page Mar 4, 2014
·
20 revisions
We try to keep the history for pdf.js relatively clean and we may ask contributors to "squash" their commits before we merge.
Note:
These directions assume that you named the Mozilla pdf.js repo (not your fork) upstream
and you have a branch called super-feature
. See Contributing for details.
- Add the following to your git config. Either the global one or the config within your pdf.js fork (
.git/config
).
[alias]
squash = !sh -c 'git checkout upstream/master && git merge --no-commit --squash $0 && git checkout -B $0 && git commit -e'
- Then you simply need to do:
git squash super-feature
- That will bring up your editor to allow you to put in the commit message you want. After entering a commit message, press Esc and type
:wq
to exit the editor (if the editor is set to vim). - Then update the pull request:
git push --force origin super-feature
- Step-by-step commands
# fetches the current upstream repository
git fetch upstream
# resets HEAD to the current upstream
git checkout upstream/master
# merges all commits from the local branch
git merge --no-commit --squash super-feature
# re-creates the branch starting from current HEAD (old commits will be lost)
git checkout -B super-feature
# lets you edit the commit and checks in the changes (you can also use git commit -m "message")
git commit -e
# pushes the changes (in general, be careful with the --force parameter)
git push --force origin super-feature
git rebase -i HEAD~5
Change pick
to squash
(or fixup
) for last four and update the commit message in the editor, then git push --force origin super-feature
.