A
A
Alexander Fanamurov2015-09-01 11:01:22
git
Alexander Fanamurov, 2015-09-01 11:01:22

How to remove all commits from a GIT repository except for the last one?

There is an old git repository with hundreds of commits. How to make the entire history of the master branch reduced to only the last commit? It should turn out as if we created a new repository, where we uploaded the files and that's it. The history of changes and all deleted/modified files are no longer needed.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Kirill, 2015-09-01
@Fanamura

This can be done via git rebase --root -i , an editor will open in which you need to specify pick for the first commit, and squash for the rest .

R
Roman Mirilaczvili, 2015-09-01
@2ord

  1. Delete .git folder with all history
  2. Reinitialize git
  3. Commit changes (commit)

T
TyzhSysAdmin, 2015-09-01
@POS_troi

This is contrary to the raison d'être of the git.
Need a new turnip - create a new turnip and transfer the files.

D
Dasha, 2015-09-01
@bizzi

make a clone of the latest version, upload it to the new repo, and delete the old one.
And then name the new repo the same as the old one)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question