Use-Case:
I am creating a clone of my repository and I wish to maintain the version history of every other file but one, lets call it "black-sheep.json"
Following is the only approach I've discovered as yet:
- Create a temporary copy of black-sheep.json, say tmp.json
- Then remove all history for black-sheep.json using this command
git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch black-sheep.json' \ --prune-empty --tag-name-filter cat -- --all
.3. Lastly rename the tmp.json to black-sheep.json
I don't like this solution! Is there a better way ?
I just realized another approach, I can squash all the commits for this particular file into a single commit.
However in this approach I have the following doubts
- How to do this in a non-interactive mode ?
- How to do this across multiple non-sequential commits ?
NOTE:
- All commits include only a single file.
- I need to implement this in code.