3

At first, I made a shallow-clone. After this, I found some old commits introducing some large files. For example, these old commits replaced a binary file again and again.

Now, I didn't want my local reposiotry containing these big changes. How can I shorten the history without recreating a new repository with git clone --depth=10?

# shallow clone
git clone --depth 100 ssh://git@10.7.222.111:/home/my_repository01.git
git log --oneline | wc -l  # the result is 100

# Now, how can I shorten the current history to 10? 
# Otherwise, I need to execute `git clone --depth=10` to recreate the repository.
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Hobin C.
  • 671
  • 1
  • 8
  • 17

1 Answers1

5

You can use git fetch --depth=10 to update the current shallow depth.

knittl
  • 246,190
  • 53
  • 318
  • 364
  • 1
    Amazing! After exeucting `git fetch --depth=10 origin master`, the result of `git log --oneline | wc -l` is 10. And I also found the [docs](https://git-scm.com/docs/git-fetch#Documentation/git-fetch.txt---depthltdepthgt). Many thanks! – Hobin C. Jul 12 '21 at 07:21