gitignore for git add












0














I want gitignore a file that is already committed and pushed to master;



Meaning, I want to ignore any change of that file.



But after I add the path in gitignore, it is still included in commit and pushed when I use



git add .


how do I ignore such file ?










share|improve this question






















  • Possible duplicate of Ignore changes to a tracked file
    – Paul Crovella
    Nov 14 '18 at 4:55






  • 1




    Possible duplicate of Can I 'git commit' a file and ignore its content changes?
    – 1615903
    Nov 14 '18 at 7:20
















0














I want gitignore a file that is already committed and pushed to master;



Meaning, I want to ignore any change of that file.



But after I add the path in gitignore, it is still included in commit and pushed when I use



git add .


how do I ignore such file ?










share|improve this question






















  • Possible duplicate of Ignore changes to a tracked file
    – Paul Crovella
    Nov 14 '18 at 4:55






  • 1




    Possible duplicate of Can I 'git commit' a file and ignore its content changes?
    – 1615903
    Nov 14 '18 at 7:20














0












0








0







I want gitignore a file that is already committed and pushed to master;



Meaning, I want to ignore any change of that file.



But after I add the path in gitignore, it is still included in commit and pushed when I use



git add .


how do I ignore such file ?










share|improve this question













I want gitignore a file that is already committed and pushed to master;



Meaning, I want to ignore any change of that file.



But after I add the path in gitignore, it is still included in commit and pushed when I use



git add .


how do I ignore such file ?







git gitignore






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 3:21









Isaac Sim

7410




7410












  • Possible duplicate of Ignore changes to a tracked file
    – Paul Crovella
    Nov 14 '18 at 4:55






  • 1




    Possible duplicate of Can I 'git commit' a file and ignore its content changes?
    – 1615903
    Nov 14 '18 at 7:20


















  • Possible duplicate of Ignore changes to a tracked file
    – Paul Crovella
    Nov 14 '18 at 4:55






  • 1




    Possible duplicate of Can I 'git commit' a file and ignore its content changes?
    – 1615903
    Nov 14 '18 at 7:20
















Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55




Possible duplicate of Ignore changes to a tracked file
– Paul Crovella
Nov 14 '18 at 4:55




1




1




Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20




Possible duplicate of Can I 'git commit' a file and ignore its content changes?
– 1615903
Nov 14 '18 at 7:20












2 Answers
2






active

oldest

votes


















0















  1. If you want the file to be removed altogether, you can delete the file locally, commit and push to master.


Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.




A gitignore file specifies intentionally untracked files that Git
should ignore. Files already tracked by Git are not affected





  1. If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in $GIT_DIR/info/exclude.


Read more information on gitignore



Read more information on ignore files locally in this stackoverflow Q&A






share|improve this answer





























    2














    You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.



    It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.



    .gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.






    share|improve this answer





















    • Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
      – Isaac Sim
      Nov 14 '18 at 5:08










    • No worries at all. The main thing we solved and explained your problem. Cheers!
      – anvk
      Nov 14 '18 at 12:31











    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',
    autoActivateHeartbeat: false,
    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%2f53292720%2fgitignore-for-git-add%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









    0















    1. If you want the file to be removed altogether, you can delete the file locally, commit and push to master.


    Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.




    A gitignore file specifies intentionally untracked files that Git
    should ignore. Files already tracked by Git are not affected





    1. If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in $GIT_DIR/info/exclude.


    Read more information on gitignore



    Read more information on ignore files locally in this stackoverflow Q&A






    share|improve this answer


























      0















      1. If you want the file to be removed altogether, you can delete the file locally, commit and push to master.


      Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.




      A gitignore file specifies intentionally untracked files that Git
      should ignore. Files already tracked by Git are not affected





      1. If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in $GIT_DIR/info/exclude.


      Read more information on gitignore



      Read more information on ignore files locally in this stackoverflow Q&A






      share|improve this answer
























        0












        0








        0







        1. If you want the file to be removed altogether, you can delete the file locally, commit and push to master.


        Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.




        A gitignore file specifies intentionally untracked files that Git
        should ignore. Files already tracked by Git are not affected





        1. If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in $GIT_DIR/info/exclude.


        Read more information on gitignore



        Read more information on ignore files locally in this stackoverflow Q&A






        share|improve this answer













        1. If you want the file to be removed altogether, you can delete the file locally, commit and push to master.


        Remember, gitignore will only work for files, not yet pushed to remote. If already pushed to remote then, it will not work.




        A gitignore file specifies intentionally untracked files that Git
        should ignore. Files already tracked by Git are not affected





        1. If you want to keep the file in master and ignore only your local changes, you can update git exclude file located in $GIT_DIR/info/exclude.


        Read more information on gitignore



        Read more information on ignore files locally in this stackoverflow Q&A







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 4:30









        Venkataraman R

        1,464918




        1,464918

























            2














            You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.



            It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.



            .gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.






            share|improve this answer





















            • Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
              – Isaac Sim
              Nov 14 '18 at 5:08










            • No worries at all. The main thing we solved and explained your problem. Cheers!
              – anvk
              Nov 14 '18 at 12:31
















            2














            You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.



            It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.



            .gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.






            share|improve this answer





















            • Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
              – Isaac Sim
              Nov 14 '18 at 5:08










            • No worries at all. The main thing we solved and explained your problem. Cheers!
              – anvk
              Nov 14 '18 at 12:31














            2












            2








            2






            You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.



            It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.



            .gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.






            share|improve this answer












            You cannot. Once the file is in Git repo it is in the Git repo. You have to remove the file from Git repo in order for .gitignore to kick in and start ignoring the file.



            It is pretty simple - it is either the file is in repo and tracked. Or the file is not in the repo and not tracked.



            .gitignore helps with the second case when there are files which are NOT in the repo and you do not want Git constantly reminding you that you might want to commit those files.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 14 '18 at 3:39









            anvk

            1,018810




            1,018810












            • Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
              – Isaac Sim
              Nov 14 '18 at 5:08










            • No worries at all. The main thing we solved and explained your problem. Cheers!
              – anvk
              Nov 14 '18 at 12:31


















            • Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
              – Isaac Sim
              Nov 14 '18 at 5:08










            • No worries at all. The main thing we solved and explained your problem. Cheers!
              – anvk
              Nov 14 '18 at 12:31
















            Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
            – Isaac Sim
            Nov 14 '18 at 5:08




            Thank you for the answer, but I checked the other answer since it is more specific and described in details with references.
            – Isaac Sim
            Nov 14 '18 at 5:08












            No worries at all. The main thing we solved and explained your problem. Cheers!
            – anvk
            Nov 14 '18 at 12:31




            No worries at all. The main thing we solved and explained your problem. Cheers!
            – anvk
            Nov 14 '18 at 12:31


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53292720%2fgitignore-for-git-add%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







            Popular posts from this blog

            How to pass form data using jquery Ajax to insert data in database?

            National Museum of Racing and Hall of Fame

            Guess what letter conforming each word