简体   繁体   English

我如何忽略github中的py〜文件

[英]how can I ignore py~ file in github

I have already a .gitignore file in my current working directory. 我的当前工作目录中已经有一个.gitignore文件。 But those py~ is still there 但是那些py〜还在那里

Have I done something wrong ? 我做错了什么吗?

This is how my .gitignore looks like 这就是我的.gitignore的样子

*.pyc
.idea/workspace.xml
*.log
.idea/dataSources.ids
*~

In your .gitignore file add: 在您的.gitignore文件中添加:

*.py~

If you already have a *.py~ in your repository, you need remove those from your repository. 如果您的存储库中已有*.py~ ,则需要从存储库中删除它们。 You can do that via this command (for one file at a time): 您可以通过以下命令来做到这一点(一次只处理一个文件):

git rm <file>

OR this for all with the extension *.py~ 或全部使用扩展名*.py~

git rm -r '*.py~' 

If you need to remove files from your repository, you need to follow these steps 如果需要从存储库中删除文件,则需要执行以下步骤

  • Commit any pending changes 提交任何未决的更改
  • Run git rm --cached <file> OR git rm -r '*.py~' 运行git rm --cached <file>git rm -r '*.py~'
  • Commit this change 提交此更改
  • Add the line to your .gitignore 将行添加到您的.gitignore
  • Commit a final time 提交最后的时间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM