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?










share|improve this question






















  • 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 recognize subdir/.gitignore, for instance, because that isn't path ./.git*, but rather path ./subdir/.git*.
    – torek
    Nov 7 at 22:30















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?










share|improve this question






















  • 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 recognize subdir/.gitignore, for instance, because that isn't path ./.git*, but rather path ./subdir/.git*.
    – torek
    Nov 7 at 22:30













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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 recognize subdir/.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










  • 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 recognize subdir/.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












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





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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





    share|improve this answer



























      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





      share|improve this answer

























        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





        share|improve this answer














        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






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 9 at 12:27

























        answered Nov 9 at 11:19









        kyb

        1,5441934




        1,5441934






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()