Linked Questions
40 questions linked to/from How to squash all git commits into one?
30
votes
2
answers
30k
views
Git: How to squash all commits on `master` branch? [duplicate]
I'm looking for a way to squash all git commits into a single big commit in master branch. I fully understand the consequences of what I'm trying to do, no need to explain that this is dangerous or ...
4
votes
1
answer
3k
views
Git -- Rewrite entire history [duplicate]
I want to do an explicitly bad thing. I have a project where I am the only developer and I want to put it on Github but it's littered with absolutely terrible commit message. I want to basically re-...
-1
votes
2
answers
1k
views
Git how to squash all the commit [duplicate]
I have try to use git rebase -i HEAD~3 to squash all the commit. But git throw below error, for the commit HEAD~3 is not exist.
fatal: invalid upstream 'HEAD~3'
$ git log --oneline
7cabc02 (HEAD -&...
-2
votes
1
answer
68
views
How can I remove all commits in git? [duplicate]
I have I repository in git and I made a lot of tests to learn it. Now I am on a level to start working. But I have all these test commits, that are disturbing me. Can I remove all commits to start ...
2
votes
0
answers
70
views
How do I squash a master branch down to one commit? [duplicate]
I have a git repository that has a lot of commits on it. These have been remotely pushed but I want to squash merge the changes down to a single commit. Is there any simple way to do that?
I suppose ...
0
votes
1
answer
36
views
How to remove the first 4 commits in git as if 5th commit was the first one? [duplicate]
I want to upload the project to remote but I can't with the first few commits.
For example I have git commits like this:
...(Many new commits)
Presentable Commit
Commit I don't want to share #4
...
5516
votes
46
answers
4.0m
views
How do I squash my last N commits together?
How do I squash my last N commits together into one commit?
939
votes
23
answers
954k
views
Git: How to squash all commits on branch
I make new branch from master with:
git checkout -b testbranch
I make 20 commits into it.
Now I want to squash those 20 commits. I do that with:
git rebase -i HEAD~20
What about if I don't know ...
898
votes
19
answers
340k
views
Make the current commit the only (initial) commit in a Git repository?
I currently have a local Git repository, which I push to a Github repository.
The local repository has ~10 commits, and the Github repository is a synchronised duplicate of this.
What I'd like to ...
694
votes
9
answers
210k
views
Squash the first two commits in Git? [duplicate]
With git rebase --interactive <commit> you can squash any number of commits together into a single one.
That's all great unless you want to squash commits into the initial commit. That seems ...
232
votes
9
answers
51k
views
Combine the first two commits of a Git repository?
Suppose you have a history containing the three commits A, B and C:
A-B-C
I would like to combine the two commits A and B to one commit AB:
AB-C
I tried
git rebase -i A
which opens up my editor ...
227
votes
7
answers
83k
views
Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?
We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, ...
214
votes
3
answers
199k
views
Git: How to reset a remote Git repository to remove all commits?
How can I reset a remote and local Git repository to remove all commits?
I would like to start fresh with the current Head as the initial commit.
165
votes
5
answers
130k
views
How to push new branch without history
I have git repo with two unrelated branches, master and configs.
I've created configs, purged all the files and then placed in configuration files only.
Now I want to push this on remote repo, but as ...
78
votes
8
answers
69k
views
git: generate a single patch across multiple commits
This is the situation:
We created a "private" repo (say our-repo) based off an existing open-source git repo (say source-repo).
We have been developing code and have around 20 merges into our repo. ...