Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 views
in Technique[技术] by (71.8m points)

version control - git, don't show me *.pyc in the list of untracked files!

When doing:

>git status

It shows a big list of .pyc files under "untracked files". I don't want it to show these, as it adds noise.

In other words, how do I make git ignore .pyc files all the time and for all projects?

EDIT

I'm not asking for a way to spread my ignored files to other people, I really just mean "for all projects", meaning I don't want to configure each new project to ignore .pyc files.

UPDATE

I should add that I'm working on windows, and my git is msysgit

Patterns which a user wants git to ignore in all situations (e.g., backup or temporary files generated by the user's editor of choice) generally go into a file specified by core.excludesfile in the user's ~/.gitconfig.

Is .gitconfig a file or a folder? I don't have such a thing in my home directory (C:users<myusername>)

UPDATE2

Thanks everybody for the responses,

I solved the issues by using:

>git config --global core.excludesfile c:gitignore_files.txt

and putting *.pyc in c:gitignore_files.txt

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As mentioned in gitignore, git has 3 ignore files:

  • Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file.

(that takes care of all time: if one clones your repo, it will get the .gitignore file)

  • Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

(not interesting in your case)

  • Patterns which a user wants git to ignore in all situations (e.g., backup or temporary files generated by the user's editor of choice) generally go into a file specified by core.excludesfile in the user's ~/.gitconfig.

(takes cares of all projects, but not all time since it is not replicated when one clones your repo.)

"All time for all projects" would means for instance a custom shell for creating new git projects, with a custom .gitignore as first file part of the first commit...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...