Add note to commit when filtering branch with Git
up vote
1
down vote
favorite
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?
git git-filter-branch git-notes
|
show 1 more comment
up vote
1
down vote
favorite
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?
git git-filter-branch git-notes
Aside: you don't need-not -path ./.git*
as--tree-filter
is run in a temporary directory that contains no.git
directory
– torek
Nov 7 at 21:00
this is not only for .git directory but mostly for .gitignore and .gitattributes
– kyb
Nov 7 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.
– torek
Nov 7 at 21:53
and gitmodules and something else ... I prefer pattern, why not?
– kyb
Nov 7 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 recognizesubdir/.gitignore
, for instance, because that isn't path./.git*
, but rather path./subdir/.git*
.
– torek
Nov 7 at 22:30
|
show 1 more comment
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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?
git git-filter-branch git-notes
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?
git git-filter-branch git-notes
git git-filter-branch git-notes
asked Nov 7 at 20:45
kyb
1,5441934
1,5441934
Aside: you don't need-not -path ./.git*
as--tree-filter
is run in a temporary directory that contains no.git
directory
– torek
Nov 7 at 21:00
this is not only for .git directory but mostly for .gitignore and .gitattributes
– kyb
Nov 7 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.
– torek
Nov 7 at 21:53
and gitmodules and something else ... I prefer pattern, why not?
– kyb
Nov 7 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 recognizesubdir/.gitignore
, for instance, because that isn't path./.git*
, but rather path./subdir/.git*
.
– torek
Nov 7 at 22:30
|
show 1 more comment
Aside: you don't need-not -path ./.git*
as--tree-filter
is run in a temporary directory that contains no.git
directory
– torek
Nov 7 at 21:00
this is not only for .git directory but mostly for .gitignore and .gitattributes
– kyb
Nov 7 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.
– torek
Nov 7 at 21:53
and gitmodules and something else ... I prefer pattern, why not?
– kyb
Nov 7 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 recognizesubdir/.gitignore
, for instance, because that isn't path./.git*
, but rather path./subdir/.git*
.
– torek
Nov 7 at 22:30
Aside: you don't need
-not -path ./.git*
as --tree-filter
is run in a temporary directory that contains no .git
directory– torek
Nov 7 at 21:00
Aside: you don't need
-not -path ./.git*
as --tree-filter
is run in a temporary directory that contains no .git
directory– torek
Nov 7 at 21:00
this is not only for .git directory but mostly for .gitignore and .gitattributes
– kyb
Nov 7 at 21:27
this is not only for .git directory but mostly for .gitignore and .gitattributes
– kyb
Nov 7 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.– torek
Nov 7 at 21:53
Ah, that makes sense, but then you probably should use
-not -name .gitignore -not -name .gitattributes
since such files can occur at any subdirectory.– torek
Nov 7 at 21:53
and gitmodules and something else ... I prefer pattern, why not?
– kyb
Nov 7 at 22:14
and gitmodules and something else ... I prefer pattern, why not?
– kyb
Nov 7 at 22:14
1
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*
.– torek
Nov 7 at 22:30
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*
.– torek
Nov 7 at 22:30
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
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
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
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
add a comment |
up vote
0
down vote
accepted
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
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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
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
edited Nov 9 at 12:27
answered Nov 9 at 11:19
kyb
1,5441934
1,5441934
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53197547%2fadd-note-to-commit-when-filtering-branch-with-git%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Aside: you don't need
-not -path ./.git*
as--tree-filter
is run in a temporary directory that contains no.git
directory– torek
Nov 7 at 21:00
this is not only for .git directory but mostly for .gitignore and .gitattributes
– kyb
Nov 7 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.– torek
Nov 7 at 21:53
and gitmodules and something else ... I prefer pattern, why not?
– kyb
Nov 7 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 recognizesubdir/.gitignore
, for instance, because that isn't path./.git*
, but rather path./subdir/.git*
.– torek
Nov 7 at 22:30