remove execute only file from git tracking





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I needed to make a file in a repository non-readable and non-writable:



sudo chmod 101 file1.sh


when you list it it looks like this:



$ ls -la file1.sh
---x-----x 1 cardamom cardamom 13 Nov 16 16:52 file1.sh


git add will not work:



error: open("file1.sh"): Permission denied
error: unable to index file file1.sh
fatal: updating files failed


and adding it to .gitignore does not cause it to be ignored.

I don't really need to track it, but would be good to not have it pop up every time git status is typed in.



How does one either add it to the repo or tell git to ignore it?










share|improve this question

























  • Possible duplicate of How to make Git "forget" about a file that was tracked but is now in .gitignore?

    – phd
    Nov 16 '18 at 20:10











  • stackoverflow.com/search?q=%5Bgitignore%5D+tracked+file

    – phd
    Nov 16 '18 at 20:10


















1















I needed to make a file in a repository non-readable and non-writable:



sudo chmod 101 file1.sh


when you list it it looks like this:



$ ls -la file1.sh
---x-----x 1 cardamom cardamom 13 Nov 16 16:52 file1.sh


git add will not work:



error: open("file1.sh"): Permission denied
error: unable to index file file1.sh
fatal: updating files failed


and adding it to .gitignore does not cause it to be ignored.

I don't really need to track it, but would be good to not have it pop up every time git status is typed in.



How does one either add it to the repo or tell git to ignore it?










share|improve this question

























  • Possible duplicate of How to make Git "forget" about a file that was tracked but is now in .gitignore?

    – phd
    Nov 16 '18 at 20:10











  • stackoverflow.com/search?q=%5Bgitignore%5D+tracked+file

    – phd
    Nov 16 '18 at 20:10














1












1








1








I needed to make a file in a repository non-readable and non-writable:



sudo chmod 101 file1.sh


when you list it it looks like this:



$ ls -la file1.sh
---x-----x 1 cardamom cardamom 13 Nov 16 16:52 file1.sh


git add will not work:



error: open("file1.sh"): Permission denied
error: unable to index file file1.sh
fatal: updating files failed


and adding it to .gitignore does not cause it to be ignored.

I don't really need to track it, but would be good to not have it pop up every time git status is typed in.



How does one either add it to the repo or tell git to ignore it?










share|improve this question
















I needed to make a file in a repository non-readable and non-writable:



sudo chmod 101 file1.sh


when you list it it looks like this:



$ ls -la file1.sh
---x-----x 1 cardamom cardamom 13 Nov 16 16:52 file1.sh


git add will not work:



error: open("file1.sh"): Permission denied
error: unable to index file file1.sh
fatal: updating files failed


and adding it to .gitignore does not cause it to be ignored.

I don't really need to track it, but would be good to not have it pop up every time git status is typed in.



How does one either add it to the repo or tell git to ignore it?







git file-permissions gitignore






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 17:11









CodeWizard

55.7k1271100




55.7k1271100










asked Nov 16 '18 at 16:31









cardamomcardamom

2,07611344




2,07611344













  • Possible duplicate of How to make Git "forget" about a file that was tracked but is now in .gitignore?

    – phd
    Nov 16 '18 at 20:10











  • stackoverflow.com/search?q=%5Bgitignore%5D+tracked+file

    – phd
    Nov 16 '18 at 20:10



















  • Possible duplicate of How to make Git "forget" about a file that was tracked but is now in .gitignore?

    – phd
    Nov 16 '18 at 20:10











  • stackoverflow.com/search?q=%5Bgitignore%5D+tracked+file

    – phd
    Nov 16 '18 at 20:10

















Possible duplicate of How to make Git "forget" about a file that was tracked but is now in .gitignore?

– phd
Nov 16 '18 at 20:10





Possible duplicate of How to make Git "forget" about a file that was tracked but is now in .gitignore?

– phd
Nov 16 '18 at 20:10













stackoverflow.com/search?q=%5Bgitignore%5D+tracked+file

– phd
Nov 16 '18 at 20:10





stackoverflow.com/search?q=%5Bgitignore%5D+tracked+file

– phd
Nov 16 '18 at 20:10












2 Answers
2






active

oldest

votes


















2















How does one either add it to the repo or tell git to ignore it?






--assume-unchaged



Raise the --assume-unchaged flag on this file so it will stop tracking changes on this file




--[no-]assume-unchanged



When this flag is specified, the object names recorded for the paths are not updated.



Instead, this option sets/unsets the assume unchanged bit for the paths.



When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).



Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.




enter image description here






share|improve this answer
























  • Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

    – cardamom
    Nov 28 '18 at 10:47



















2














adding it to .gitignore won't work on a revision that is tracking it because the file is already tracked..... it will work on revisions after you delete it (and commit). Then, if you remove all permissions from the file, how do you expect git to be able to use it? It can't read it. So... if you don't mind having the file in history and then disappear, you could delete it (git rm --cached the-file), add it to .gitignore, then commit. For revisions starting with this revision the file won't show up to be added anymore. If you, however, chose to checkout to previous revisions, don't be surprised to see git behave funny because of the file being present on your working tree.






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',
    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%2f53341908%2fremove-execute-only-file-from-git-tracking%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









    2















    How does one either add it to the repo or tell git to ignore it?






    --assume-unchaged



    Raise the --assume-unchaged flag on this file so it will stop tracking changes on this file




    --[no-]assume-unchanged



    When this flag is specified, the object names recorded for the paths are not updated.



    Instead, this option sets/unsets the assume unchanged bit for the paths.



    When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).



    Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.




    enter image description here






    share|improve this answer
























    • Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

      – cardamom
      Nov 28 '18 at 10:47
















    2















    How does one either add it to the repo or tell git to ignore it?






    --assume-unchaged



    Raise the --assume-unchaged flag on this file so it will stop tracking changes on this file




    --[no-]assume-unchanged



    When this flag is specified, the object names recorded for the paths are not updated.



    Instead, this option sets/unsets the assume unchanged bit for the paths.



    When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).



    Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.




    enter image description here






    share|improve this answer
























    • Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

      – cardamom
      Nov 28 '18 at 10:47














    2












    2








    2








    How does one either add it to the repo or tell git to ignore it?






    --assume-unchaged



    Raise the --assume-unchaged flag on this file so it will stop tracking changes on this file




    --[no-]assume-unchanged



    When this flag is specified, the object names recorded for the paths are not updated.



    Instead, this option sets/unsets the assume unchanged bit for the paths.



    When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).



    Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.




    enter image description here






    share|improve this answer














    How does one either add it to the repo or tell git to ignore it?






    --assume-unchaged



    Raise the --assume-unchaged flag on this file so it will stop tracking changes on this file




    --[no-]assume-unchanged



    When this flag is specified, the object names recorded for the paths are not updated.



    Instead, this option sets/unsets the assume unchanged bit for the paths.



    When the assume unchanged bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).



    Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.




    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 16 '18 at 17:11









    CodeWizardCodeWizard

    55.7k1271100




    55.7k1271100













    • Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

      – cardamom
      Nov 28 '18 at 10:47



















    • Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

      – cardamom
      Nov 28 '18 at 10:47

















    Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

    – cardamom
    Nov 28 '18 at 10:47





    Weeks later it wouldn't let me checkout master. Turns out as well as update-index, they also needed to go in .gitignore, the command git status --porcelain | grep '^??' | cut -c4- >> .gitignore from here was helpful.

    – cardamom
    Nov 28 '18 at 10:47













    2














    adding it to .gitignore won't work on a revision that is tracking it because the file is already tracked..... it will work on revisions after you delete it (and commit). Then, if you remove all permissions from the file, how do you expect git to be able to use it? It can't read it. So... if you don't mind having the file in history and then disappear, you could delete it (git rm --cached the-file), add it to .gitignore, then commit. For revisions starting with this revision the file won't show up to be added anymore. If you, however, chose to checkout to previous revisions, don't be surprised to see git behave funny because of the file being present on your working tree.






    share|improve this answer




























      2














      adding it to .gitignore won't work on a revision that is tracking it because the file is already tracked..... it will work on revisions after you delete it (and commit). Then, if you remove all permissions from the file, how do you expect git to be able to use it? It can't read it. So... if you don't mind having the file in history and then disappear, you could delete it (git rm --cached the-file), add it to .gitignore, then commit. For revisions starting with this revision the file won't show up to be added anymore. If you, however, chose to checkout to previous revisions, don't be surprised to see git behave funny because of the file being present on your working tree.






      share|improve this answer


























        2












        2








        2







        adding it to .gitignore won't work on a revision that is tracking it because the file is already tracked..... it will work on revisions after you delete it (and commit). Then, if you remove all permissions from the file, how do you expect git to be able to use it? It can't read it. So... if you don't mind having the file in history and then disappear, you could delete it (git rm --cached the-file), add it to .gitignore, then commit. For revisions starting with this revision the file won't show up to be added anymore. If you, however, chose to checkout to previous revisions, don't be surprised to see git behave funny because of the file being present on your working tree.






        share|improve this answer













        adding it to .gitignore won't work on a revision that is tracking it because the file is already tracked..... it will work on revisions after you delete it (and commit). Then, if you remove all permissions from the file, how do you expect git to be able to use it? It can't read it. So... if you don't mind having the file in history and then disappear, you could delete it (git rm --cached the-file), add it to .gitignore, then commit. For revisions starting with this revision the file won't show up to be added anymore. If you, however, chose to checkout to previous revisions, don't be surprised to see git behave funny because of the file being present on your working tree.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 16:35









        eftshift0eftshift0

        5,9221022




        5,9221022






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53341908%2fremove-execute-only-file-from-git-tracking%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

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python