Trying to ignore .pyc extension in .gitignore [duplicate]












0
















This question already has an answer here:




  • How to make Git “forget” about a file that was tracked but is now in .gitignore?

    21 answers




I am trying to ignore all .pyc extensions in the repository
my .gitignore file looks like this



.idea
*.rdb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pyc
__pycache__/


however when I do git status. I get information on modified files like this



On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: .DS_Store
modified: .gitignore
modified: Device/__init__.py
modified: Device/admin.py
modified: Device/apps.py
modified: Device/migrations/0001_initial.py
modified: Device/migrations/__init__.py
modified: Employee/__init__.py
modified: Employee/__pycache__/__init__.cpython-35.pyc


Notice the last file .pyc is shown as modified and also the foled pycache which is added to .gitignore also gets shown. How do I get git to ignore them ?










share|improve this question















marked as duplicate by Edward Thomson git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 27 '18 at 10:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Those files are already in your repository, and are currently tracked (i.e., in your index). Listing them in .gitignore has no effect. You must make them untracked: see stackoverflow.com/questions/936249/…

    – torek
    Nov 27 '18 at 9:11
















0
















This question already has an answer here:




  • How to make Git “forget” about a file that was tracked but is now in .gitignore?

    21 answers




I am trying to ignore all .pyc extensions in the repository
my .gitignore file looks like this



.idea
*.rdb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pyc
__pycache__/


however when I do git status. I get information on modified files like this



On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: .DS_Store
modified: .gitignore
modified: Device/__init__.py
modified: Device/admin.py
modified: Device/apps.py
modified: Device/migrations/0001_initial.py
modified: Device/migrations/__init__.py
modified: Employee/__init__.py
modified: Employee/__pycache__/__init__.cpython-35.pyc


Notice the last file .pyc is shown as modified and also the foled pycache which is added to .gitignore also gets shown. How do I get git to ignore them ?










share|improve this question















marked as duplicate by Edward Thomson git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 27 '18 at 10:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Those files are already in your repository, and are currently tracked (i.e., in your index). Listing them in .gitignore has no effect. You must make them untracked: see stackoverflow.com/questions/936249/…

    – torek
    Nov 27 '18 at 9:11














0












0








0









This question already has an answer here:




  • How to make Git “forget” about a file that was tracked but is now in .gitignore?

    21 answers




I am trying to ignore all .pyc extensions in the repository
my .gitignore file looks like this



.idea
*.rdb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pyc
__pycache__/


however when I do git status. I get information on modified files like this



On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: .DS_Store
modified: .gitignore
modified: Device/__init__.py
modified: Device/admin.py
modified: Device/apps.py
modified: Device/migrations/0001_initial.py
modified: Device/migrations/__init__.py
modified: Employee/__init__.py
modified: Employee/__pycache__/__init__.cpython-35.pyc


Notice the last file .pyc is shown as modified and also the foled pycache which is added to .gitignore also gets shown. How do I get git to ignore them ?










share|improve this question

















This question already has an answer here:




  • How to make Git “forget” about a file that was tracked but is now in .gitignore?

    21 answers




I am trying to ignore all .pyc extensions in the repository
my .gitignore file looks like this



.idea
*.rdb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*.pyc
__pycache__/


however when I do git status. I get information on modified files like this



On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: .DS_Store
modified: .gitignore
modified: Device/__init__.py
modified: Device/admin.py
modified: Device/apps.py
modified: Device/migrations/0001_initial.py
modified: Device/migrations/__init__.py
modified: Employee/__init__.py
modified: Employee/__pycache__/__init__.cpython-35.pyc


Notice the last file .pyc is shown as modified and also the foled pycache which is added to .gitignore also gets shown. How do I get git to ignore them ?





This question already has an answer here:




  • How to make Git “forget” about a file that was tracked but is now in .gitignore?

    21 answers








git






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 9:13









torek

193k18239321




193k18239321










asked Nov 27 '18 at 9:06









MistyDMistyD

4,1891472141




4,1891472141




marked as duplicate by Edward Thomson git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 27 '18 at 10:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Edward Thomson git
Users with the  git badge can single-handedly close git questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 27 '18 at 10:41


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    Those files are already in your repository, and are currently tracked (i.e., in your index). Listing them in .gitignore has no effect. You must make them untracked: see stackoverflow.com/questions/936249/…

    – torek
    Nov 27 '18 at 9:11














  • 1





    Those files are already in your repository, and are currently tracked (i.e., in your index). Listing them in .gitignore has no effect. You must make them untracked: see stackoverflow.com/questions/936249/…

    – torek
    Nov 27 '18 at 9:11








1




1





Those files are already in your repository, and are currently tracked (i.e., in your index). Listing them in .gitignore has no effect. You must make them untracked: see stackoverflow.com/questions/936249/…

– torek
Nov 27 '18 at 9:11





Those files are already in your repository, and are currently tracked (i.e., in your index). Listing them in .gitignore has no effect. You must make them untracked: see stackoverflow.com/questions/936249/…

– torek
Nov 27 '18 at 9:11












1 Answer
1






active

oldest

votes


















1














It seems like your .pyc file was added before you commited the .gitignore.



Try to first remove everything that is tracked by:



git rm -r --cached .


OR:



git rm -r --cached Employee/__pycache__/__init__.cpython-35.pyc


Now, try:



git add .





share|improve this answer






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    It seems like your .pyc file was added before you commited the .gitignore.



    Try to first remove everything that is tracked by:



    git rm -r --cached .


    OR:



    git rm -r --cached Employee/__pycache__/__init__.cpython-35.pyc


    Now, try:



    git add .





    share|improve this answer




























      1














      It seems like your .pyc file was added before you commited the .gitignore.



      Try to first remove everything that is tracked by:



      git rm -r --cached .


      OR:



      git rm -r --cached Employee/__pycache__/__init__.cpython-35.pyc


      Now, try:



      git add .





      share|improve this answer


























        1












        1








        1







        It seems like your .pyc file was added before you commited the .gitignore.



        Try to first remove everything that is tracked by:



        git rm -r --cached .


        OR:



        git rm -r --cached Employee/__pycache__/__init__.cpython-35.pyc


        Now, try:



        git add .





        share|improve this answer













        It seems like your .pyc file was added before you commited the .gitignore.



        Try to first remove everything that is tracked by:



        git rm -r --cached .


        OR:



        git rm -r --cached Employee/__pycache__/__init__.cpython-35.pyc


        Now, try:



        git add .






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 27 '18 at 10:31









        Mr.TurtleMr.Turtle

        1,10821226




        1,10821226

















            Popular posts from this blog

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks