0

For reasons outside of my control, I am working with a repository that has many copies of similar content (a small OS). This means that while the repo size is fairly small, the working directory takes multiple hours to checkout on my system.

The specific tasks being performed is doing a git replace --graft to concatenate linear histories, then doing git filter-branch --tag-filter cat -- master to make the change permanent.

My issue is that filter-branch requires a clean working copy (such as generated by git checkout . or a standard git clone <URL>). This increases run time to several hours, which is undesirable. Is there a faster way to do this? The actual re-write takes about 30 seconds (all blobs stay the same, just the pointers change).

4
  • please, define "dirty" Commented Jul 1, 2019 at 18:37
  • @OznOg: Index does not match HEAD. git filter-branch generates an error "Cannot rewrite branch(es) with a dirty working directory." Commented Jul 1, 2019 at 18:39
  • 1
    If you can, don't do it that way at all. Do it on a bare clone of your existing clone instead. Commented Jul 1, 2019 at 18:51
  • I am about 99% sure I had tried this previously and ran into an issue, but using the bare repo works now, and I don't remember the issue in detail. Commented Jul 1, 2019 at 19:12

2 Answers 2

1

You can create a bare clone and do all filtering there:

git clone --bare source bare cd bare git filter-branch master # this is a no-op here, but you get the idea 
Sign up to request clarification or add additional context in comments.

1 Comment

I am about 99% sure I had tried this previously and ran into an issue, but it works now, and I don't remember the issue in detail. Thank you.
1

Some ideas.

1) stash your local changes, then pop them back when you are done.

2) create a new clone but use git clone --reference to speed it up.

1 Comment

I am not making local changes, I just don't want to check out the files at all. I am already cloning from a local source, but the working copy is simply massive (copying the git objects takes about 10 seconds, but checking out the tree takes hours).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.