Hobin C.
Hobin C.

Reputation: 761

Can I shorten the history of a git repository

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://[email protected]:/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.

Upvotes: 5

Views: 567

Answers (1)

knittl
knittl

Reputation: 265201

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

Upvotes: 6

Related Questions