1

Sometimes I clone git repo not for a development - but just for the bleeding edge version. Now I do it with

git clone --depth=1 <URL>

but back then I didn't know it. So I have some full repos - and I would like to leave only the latest shapshot in each of them. How this can be done?

Edit:

I think that if I will do

rm -rf .git
git init
git add .
git commit

I will lose the origin source - and would not be able to git pull later.

Edit 2:

Perhaps the simplest way is just to delete the repos and

git clone --depth=1 <URL>

them again.

Adobe
  • 12,967
  • 10
  • 85
  • 126
  • possible duplicate of [Git squash all commits into a single commit](http://stackoverflow.com/questions/1657017/git-squash-all-commits-into-a-single-commit) – CharlesB May 10 '12 at 08:31

1 Answers1

2

You can, more simply, clone these repositories with the same --depth=1, and copy the remote repo's config (see .git/config file in old repo and copy relevant section to the one in your new repo.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • i.e. `git clone --depth=1 /path/to/extant/repo newrepo && cd newrepo && cp /path/to/extant/repo/.git/config .git/config` – Asherah May 10 '12 at 08:58