How to set different commit message for directories and files









up vote
-1
down vote

favorite












I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:



root_directory/sub_directory/file_1
root_directory/sub_directory/file_2
cd root_directory


When committing like this...



git commit -m "file_1 description" sub_directory/file_1
git commit -m "file_2 description" sub_directory/file_2


... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:



1) file_1 gets description: "file_1 description"
2) file_2 gets description: "file_2 description"
3) sub_directory gets description: "file_2 description"


Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?










share|improve this question



























    up vote
    -1
    down vote

    favorite












    I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:



    root_directory/sub_directory/file_1
    root_directory/sub_directory/file_2
    cd root_directory


    When committing like this...



    git commit -m "file_1 description" sub_directory/file_1
    git commit -m "file_2 description" sub_directory/file_2


    ... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:



    1) file_1 gets description: "file_1 description"
    2) file_2 gets description: "file_2 description"
    3) sub_directory gets description: "file_2 description"


    Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?










    share|improve this question

























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:



      root_directory/sub_directory/file_1
      root_directory/sub_directory/file_2
      cd root_directory


      When committing like this...



      git commit -m "file_1 description" sub_directory/file_1
      git commit -m "file_2 description" sub_directory/file_2


      ... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:



      1) file_1 gets description: "file_1 description"
      2) file_2 gets description: "file_2 description"
      3) sub_directory gets description: "file_2 description"


      Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?










      share|improve this question















      I can't figure out how to make a commit to GitHub where directories and data files get different descriptions. Are this kind of commits possible? For example:



      root_directory/sub_directory/file_1
      root_directory/sub_directory/file_2
      cd root_directory


      When committing like this...



      git commit -m "file_1 description" sub_directory/file_1
      git commit -m "file_2 description" sub_directory/file_2


      ... subdirectory and datafiles get the same message and the message of subdirectory is equal to last commit:



      1) file_1 gets description: "file_1 description"
      2) file_2 gets description: "file_2 description"
      3) sub_directory gets description: "file_2 description"


      Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?







      git






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 10:36









      CodeWizard

      49.1k126688




      49.1k126688










      asked Nov 10 at 10:23









      Jane Mänd

      1




      1






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          When you commit git apply the commit message to all the files in the index.



          If you wish to give different commit to each file(s) simply add them one by one and commit.



          # Add file 1
          git add sub_directory/file_1

          # now your file 1 will get the desired message
          git commit -m "file_1 description"

          ...
          # Add file 2
          git add sub_directory/file_2 && git commit -m "file_2 description"



          In shorts: how git commit work



          When you execute git commit git take a snapshot of all your files in the index.

          Those files are the ones from the previous commit along with the new/modified ones.



          git commit -m... simply take the snapshot and generate metadata for it with the following information
          enter image description here



          The content of this commit is the following:
          enter image description here



          And all those files gets the same commit message






          share|improve this answer





























            up vote
            0
            down vote













            These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)



            As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.



            Incidentally:




            Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?




            I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).






            share|improve this answer






















            • Are you sure you mean “git doesn’t store files, but changes”?
              – evolutionxbox
              Nov 11 at 2:19










            • Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
              – David Z
              Nov 11 at 2:22










            • Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
              – evolutionxbox
              Nov 11 at 2:26










            • You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
              – David Z
              Nov 11 at 2:29






            • 1




              Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
              – David Z
              Nov 11 at 2:49










            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%2f53237997%2fhow-to-set-different-commit-message-for-directories-and-files%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            When you commit git apply the commit message to all the files in the index.



            If you wish to give different commit to each file(s) simply add them one by one and commit.



            # Add file 1
            git add sub_directory/file_1

            # now your file 1 will get the desired message
            git commit -m "file_1 description"

            ...
            # Add file 2
            git add sub_directory/file_2 && git commit -m "file_2 description"



            In shorts: how git commit work



            When you execute git commit git take a snapshot of all your files in the index.

            Those files are the ones from the previous commit along with the new/modified ones.



            git commit -m... simply take the snapshot and generate metadata for it with the following information
            enter image description here



            The content of this commit is the following:
            enter image description here



            And all those files gets the same commit message






            share|improve this answer


























              up vote
              0
              down vote













              When you commit git apply the commit message to all the files in the index.



              If you wish to give different commit to each file(s) simply add them one by one and commit.



              # Add file 1
              git add sub_directory/file_1

              # now your file 1 will get the desired message
              git commit -m "file_1 description"

              ...
              # Add file 2
              git add sub_directory/file_2 && git commit -m "file_2 description"



              In shorts: how git commit work



              When you execute git commit git take a snapshot of all your files in the index.

              Those files are the ones from the previous commit along with the new/modified ones.



              git commit -m... simply take the snapshot and generate metadata for it with the following information
              enter image description here



              The content of this commit is the following:
              enter image description here



              And all those files gets the same commit message






              share|improve this answer
























                up vote
                0
                down vote










                up vote
                0
                down vote









                When you commit git apply the commit message to all the files in the index.



                If you wish to give different commit to each file(s) simply add them one by one and commit.



                # Add file 1
                git add sub_directory/file_1

                # now your file 1 will get the desired message
                git commit -m "file_1 description"

                ...
                # Add file 2
                git add sub_directory/file_2 && git commit -m "file_2 description"



                In shorts: how git commit work



                When you execute git commit git take a snapshot of all your files in the index.

                Those files are the ones from the previous commit along with the new/modified ones.



                git commit -m... simply take the snapshot and generate metadata for it with the following information
                enter image description here



                The content of this commit is the following:
                enter image description here



                And all those files gets the same commit message






                share|improve this answer














                When you commit git apply the commit message to all the files in the index.



                If you wish to give different commit to each file(s) simply add them one by one and commit.



                # Add file 1
                git add sub_directory/file_1

                # now your file 1 will get the desired message
                git commit -m "file_1 description"

                ...
                # Add file 2
                git add sub_directory/file_2 && git commit -m "file_2 description"



                In shorts: how git commit work



                When you execute git commit git take a snapshot of all your files in the index.

                Those files are the ones from the previous commit along with the new/modified ones.



                git commit -m... simply take the snapshot and generate metadata for it with the following information
                enter image description here



                The content of this commit is the following:
                enter image description here



                And all those files gets the same commit message







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 10 at 10:35

























                answered Nov 10 at 10:27









                CodeWizard

                49.1k126688




                49.1k126688






















                    up vote
                    0
                    down vote













                    These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)



                    As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.



                    Incidentally:




                    Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?




                    I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).






                    share|improve this answer






















                    • Are you sure you mean “git doesn’t store files, but changes”?
                      – evolutionxbox
                      Nov 11 at 2:19










                    • Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
                      – David Z
                      Nov 11 at 2:22










                    • Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
                      – evolutionxbox
                      Nov 11 at 2:26










                    • You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
                      – David Z
                      Nov 11 at 2:29






                    • 1




                      Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
                      – David Z
                      Nov 11 at 2:49














                    up vote
                    0
                    down vote













                    These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)



                    As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.



                    Incidentally:




                    Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?




                    I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).






                    share|improve this answer






















                    • Are you sure you mean “git doesn’t store files, but changes”?
                      – evolutionxbox
                      Nov 11 at 2:19










                    • Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
                      – David Z
                      Nov 11 at 2:22










                    • Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
                      – evolutionxbox
                      Nov 11 at 2:26










                    • You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
                      – David Z
                      Nov 11 at 2:29






                    • 1




                      Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
                      – David Z
                      Nov 11 at 2:49












                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)



                    As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.



                    Incidentally:




                    Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?




                    I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).






                    share|improve this answer














                    These "descriptions" you're talking about are associated with commits, not with individual files or directories. (They're actually called "commit messages" for that reason.)



                    As far as I know, git does not contain the functionality to associate a description with a file or directory, but that's not really what it's meant for anyway. git is built to help you organize changes to files, not so much to help you organize the files themselves. That's part of why you can give a commit (a set of changes) a description, but you can't give an individual file a description.



                    Incidentally:




                    Or do I have to make 'git init' in every subdirectory and then make commits separately in these subdirectories?




                    I wouldn't recommend that. Having nested git repositories, as you would have if you ran git init in every subdirectory, can get fairly complicated and causes more trouble than it's worth unless you're using it for a very specific reason (which would not apply in your case).







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 11 at 2:47

























                    answered Nov 10 at 10:27









                    David Z

                    93.6k17197236




                    93.6k17197236











                    • Are you sure you mean “git doesn’t store files, but changes”?
                      – evolutionxbox
                      Nov 11 at 2:19










                    • Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
                      – David Z
                      Nov 11 at 2:22










                    • Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
                      – evolutionxbox
                      Nov 11 at 2:26










                    • You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
                      – David Z
                      Nov 11 at 2:29






                    • 1




                      Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
                      – David Z
                      Nov 11 at 2:49
















                    • Are you sure you mean “git doesn’t store files, but changes”?
                      – evolutionxbox
                      Nov 11 at 2:19










                    • Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
                      – David Z
                      Nov 11 at 2:22










                    • Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
                      – evolutionxbox
                      Nov 11 at 2:26










                    • You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
                      – David Z
                      Nov 11 at 2:29






                    • 1




                      Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
                      – David Z
                      Nov 11 at 2:49















                    Are you sure you mean “git doesn’t store files, but changes”?
                    – evolutionxbox
                    Nov 11 at 2:19




                    Are you sure you mean “git doesn’t store files, but changes”?
                    – evolutionxbox
                    Nov 11 at 2:19












                    Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
                    – David Z
                    Nov 11 at 2:22




                    Did I say that somewhere in my answer? I'm not seeing it, but I could be missing something.
                    – David Z
                    Nov 11 at 2:22












                    Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
                    – evolutionxbox
                    Nov 11 at 2:26




                    Second paragraph, second half of first sentence. I had also thought this to be true until fairly recently.
                    – evolutionxbox
                    Nov 11 at 2:26












                    You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
                    – David Z
                    Nov 11 at 2:29




                    You mean "...but that's not really what it's meant for anyway"? Or are you talking about the first half of the second sentence, "git tracks changes to files, not the files themselves"? In the latter case, yes, I did mean what I wrote, though now that I look at it again, it could probably be expressed more clearly. I'll edit.
                    – David Z
                    Nov 11 at 2:29




                    1




                    1




                    Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
                    – David Z
                    Nov 11 at 2:49




                    Sure, but I wasn't talking about what git actually stores - that is, I didn't mean to say anything about how it's actually implemented under the hood. What I had in mind was the purpose of git and the workflow you get into when using it, which is centered on changes/change sets rather than individual files. Hopefully that's a little more clear after my edit. (Thanks for the feedback BTW!)
                    – David Z
                    Nov 11 at 2:49

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237997%2fhow-to-set-different-commit-message-for-directories-and-files%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







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3