Timeline for How to squash all git commits into one?
Current License: CC BY-SA 4.0
32 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 16 at 10:26 | comment | added | Anly |
This was exactly what I was looking for. I did use -F msg.txt instead of -m "A new start" because a big multiline message was unwieldy on the command line, or the stdin. (I kept the squashed commit messages and datetimes this way)
|
|
Jan 26 at 2:23 | comment | added | ryenus |
@TayJen, there's a reason for this to be named squash-all :-) you should have used git rebase -i ... or git rebase --onto ... , nevertheless you can use git reflog to find the previous HEAD, then reset back.
|
|
Jan 25 at 13:15 | comment | added | TayJen | completely ruined my branch, squashing commits of other members (did git rebase before) | |
Jan 19 at 8:29 | comment | added | MichaelStoner |
If you get zsh: no matches found: HEAD^{tree} as per another answer below stackoverflow.com/a/72665652/289688 zsh may need unsetopt nomatch or the ^ escaped like so \^ to give git reset $(git commit-tree HEAD\^{tree} -m "A new start") .
|
|
Feb 21, 2023 at 3:30 | comment | added | ryenus | @benny, on Windows this requires Git Bash, it doesn't work in cmd though. | |
Feb 21, 2023 at 3:28 | history | edited | ryenus | CC BY-SA 4.0 |
added 136 characters in body
|
Feb 17, 2023 at 23:44 | comment | added | Benny Code |
Getting error error: unknown switch m'` with git version 2.36.0.windows.1
|
|
Jan 14, 2023 at 8:11 | history | edited | ryenus | CC BY-SA 4.0 |
deleted 18 characters in body
|
Jan 14, 2023 at 5:48 | history | edited | ryenus | CC BY-SA 4.0 |
Update `git squash-all` to take all options that accepted by `git commit-tree` via `$@`.
|
Apr 5, 2022 at 17:36 | comment | added | Bernardo Dal Corno | will this work for getting multiple template repos? History like "initial commit", "template 1", "template 2", etc. | |
Sep 4, 2020 at 16:39 | history | edited | ryenus | CC BY-SA 4.0 |
deleted 9 characters in body
|
Oct 17, 2017 at 13:35 | history | edited | ryenus | CC BY-SA 3.0 |
deleted 2 characters in body
|
Oct 13, 2017 at 20:57 | comment | added | Elliot Cameron |
You could get rid of that "Caveat" but just using ${1?Please enter a message}
|
|
Aug 11, 2017 at 4:11 | history | edited | ryenus | CC BY-SA 3.0 |
added 6 characters in body
|
Aug 11, 2017 at 2:58 | history | edited | ryenus | CC BY-SA 3.0 |
remove dup
|
Aug 11, 2017 at 2:42 | history | edited | ryenus | CC BY-SA 3.0 |
add a section for the update about the alias `git squash-all`
|
Aug 11, 2017 at 2:33 | history | edited | ryenus | CC BY-SA 3.0 |
create an alias
|
Aug 18, 2016 at 11:45 | comment | added | denns |
thanks for this awesome one liner!!! i like to add that if you already pushed your project into your remote, this will only work on unprotected branches. to push this into your repo you will need to force push with push -f
|
|
Jun 29, 2015 at 2:06 | comment | added | ryenus |
Note about git checkout --orphan , this command can also be used to create a root commit, but it only does the preparation (things are only staged, not committed), and it must be followed by git commit -m "commit message" , which is slower, but can be used interactively so one has a chance to make some change before committing.
|
|
Feb 7, 2015 at 19:57 | comment | added | user23987 |
I found this answer while looking for a way to start a new project from a project template repository that didn't involve git clone . If you add --hard to git reset and switch HEAD with FETCH_HEAD in the git commit-tree you can create an initial commit after fetching the template repo. I've edited the answer with a section at the end demonstrating this.
|
|
Feb 7, 2015 at 19:55 | history | edited | user23987 | CC BY-SA 3.0 |
a variation is useful for starting a new project from a project template repo
|
Oct 28, 2014 at 12:20 | comment | added | ryenus |
@aleclarson, this only reset the current branch in the local repository, use git push -f for propagation.
|
|
Oct 28, 2014 at 7:41 | comment | added | aleclarson | Does this reset both the local and remote repository, or just one of them? | |
Sep 10, 2014 at 13:37 | history | edited | ryenus | CC BY-SA 3.0 |
added 33 characters in body
|
Aug 7, 2014 at 23:58 | history | edited | ryenus | CC BY-SA 3.0 |
added 94 characters in body
|
Aug 3, 2014 at 2:50 | history | edited | ryenus | CC BY-SA 3.0 |
added 94 characters in body
|
Aug 2, 2014 at 23:49 | history | edited | ryenus | CC BY-SA 3.0 |
deleted 64 characters in body
|
Jun 24, 2014 at 12:21 | history | edited | ryenus | CC BY-SA 3.0 |
add information about the tree object syntax and reference
|
Jun 23, 2014 at 23:45 | comment | added | Colin Bowern | The git revision syntax (HEAD^{tree}) syntax is explained here in case anyone else was wondering: jk.gs/gitrevisions.html | |
May 6, 2014 at 6:08 | history | edited | ryenus | CC BY-SA 3.0 |
added 118 characters in body
|
May 6, 2014 at 5:57 | history | edited | ryenus | CC BY-SA 3.0 |
added 36 characters in body
|
May 6, 2014 at 5:45 | history | answered | ryenus | CC BY-SA 3.0 |