1

Next command is to store commit history and files lists but remove file contents in order to minimalize disk space and network traffic consumption when need to get know history of huge repo without fetching large objects. This allows to save much time.

git filter-branch -f -d `mktemp -d` \ --tree-filter ' find . -type f -not -path ./.git\* | while read file; do > "$file"; done ' \ --msg-filter ' cat - && echo && echo "commit $GIT_COMMIT" ' \ -- metainfo/$BRANCH 

I also need to know the source commit hash. It is appended to commit message as you can see in --msg-filter part.

I would like to store source commit hash in git notes.

Is it possible? How?

6
  • Aside: you don't need -not -path ./.git\* as --tree-filter is run in a temporary directory that contains no .git directory Commented Nov 7, 2018 at 21:00
  • this is not only for .git directory but mostly for .gitignore and .gitattributes Commented Nov 7, 2018 at 21:27
  • Ah, that makes sense, but then you probably should use -not -name .gitignore -not -name .gitattributes since such files can occur at any subdirectory. Commented Nov 7, 2018 at 21:53
  • and gitmodules and something else ... I prefer pattern, why not? Commented Nov 7, 2018 at 22:14
  • 1
    Well, .gitmodules should only occur at the top level, so there -path makes sense. The problem with -path ./.git\* is that it won't recognize subdir/.gitignore, for instance, because that isn't path ./.git*, but rather path ./subdir/.git*. Commented Nov 7, 2018 at 22:30

1 Answer 1

0

Simple solution: do not change commit message, but create file.

git filter-branch -f -d `mktemp -d` \ --tree-filter ' find . -type f -not -path ./\*/.git\* | while read file; do > "$file"; done echo "$GIT_COMMIT" >.GIT_COMMIT ' \ -- metainfo/$BRANCH 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.