Linked Questions

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 ...
milosmns's user avatar
  • 3,734
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-...
Patrick Cauley's user avatar
-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 -&...
LF-DevJourney's user avatar
-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 ...
peace_love's user avatar
  • 6,391
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 ...
locka's user avatar
  • 5,949
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 ...
Nikoloz Miruashvili's user avatar
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?
markdorison's user avatar
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 ...
user3803850's user avatar
  • 9,547
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 ...
kaese's user avatar
  • 10.5k
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 ...
kch's user avatar
  • 79k
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 ...
Christian's user avatar
  • 10.1k
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, ...
Ben Hocking's user avatar
  • 7,970
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.
Priyank Bolia's user avatar
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 ...
Tomas Pruzina's user avatar
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. ...
SimpleCoder's user avatar
  • 1,253

15 30 50 per page