Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dropping older Git commits from history?

Tags:

git

git-svn

I have cloned an SVN repository into a Git repository, and I just want the last commits beginning from f3a5b2a commit. I do want to retain the changes, but they can be part of that f3a5b2a commit, I want to get rid of the unnecessary history because I don't need it anymore and I have the old SVN repository backed up.

There are commits spanning across 7 years, I just want the commits beginning from f3a5b2a.

like image 388
Tower Avatar asked Aug 09 '12 09:08

Tower


People also ask

Can I remove git commit from history?

Luckily, you can process your files with Git and remove from commit and fix the history. If you've made several commits or cloned a repository with an already existing commit history, you'd typically want to look back and see what all commits were made.

How do I clean up commit history?

It's cleanup time ⏰ If you have been lazily writing multiple vague commits, you can use git reset --soft <old-commit> to make your branch point to that old commit. And as we learned, Git will start by moving the branch pointer to it and stops right there.


1 Answers

I found a better way to clone an SVN repository and dropping older commits:

git svn clone -r1234:HEAD https://asdasd/ targetPath

It basically clones the given SVN repository, starting from revision 1234 until it hits the head.

like image 94
Tower Avatar answered Sep 21 '22 15:09

Tower