A few ways to tell Git which files to ignore.
来源:互联网 发布:mac pretty boy 编辑:程序博客网 时间:2024/06/04 19:36
原文地址:https://help.github.com/articles/ignoring-files/
Ignoring files
From time to time, there are files you don't want Git to check in to GitHub. There are a few ways to tell Git which files to ignore.
Create a local .gitignore
If you create a file in your repository named .gitignore, Git uses it to determine which files and directories to ignore, before you make a commit.
A .gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.
GitHub maintains an official list of recommended .gitignore files for many popular operating systems, environments, and languages in the github/gitignore
public repository.
- In Terminal, navigate to the location of your Git repository.
- Enter
touch .gitignore
to create a .gitignore file.
The Octocat has a Gist containing some good rules to add to this file.
If you already have a file checked in, and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
git rm --cached FILENAME
Create a global .gitignore
You can also create a global .gitignore file, which is a list of rules for ignoring files in every Git repositories on your computer. For example, you might create the file at ~/.gitignore_global and add some rules to it.
- Open Terminal.
- Run the following command in your terminal:
git config --global core.excludesfile ~/.gitignore_global
The Octocat has a Gist containing some good rules to add to this file.
Explicit repository excludes
If you don't want to create a .gitignore file to share with others, you can create rules that are not committed with the repository. You can use this technique for locally-generated files that you don't expect other users to generate, such as files created by your editor.
Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.
- In Terminal, navigate to the location of your Git repository.
- Using your favorite text editor, open the file .git/info/exclude.
- A few ways to tell Git which files to ignore.
- 12 Ways to tell if your a Hightech Redneck
- Ways to write & read HDFS files
- git ignore modified files
- git 提交ignore files
- git ignore files配置
- [Django] Tell your site how to load the template files?
- git adding files to index has encountered a problem
- From Java to Groovy in a few easy steps
- a few useful things to know about machine learning
- A Few Things To Do For The New Year
- A Few Useful Things to Know about Machine Learning
- Introduction to Networking: Part 2, A Few More Basics
- 《A Few useful things to Know About machine Learning》读后感
- A Few Useful Things to Know About Machine Learning
- A Few Useful Things to Know about Machine Learning
- CS231n A Few Useful Things to Know about Machine Learning
- A Few Useful Things to Know about Machine Learning
- IOS your app stores 18.79MB on the user's iCloud 应用被拒问题,
- jvm内存溢出解决办法
- Java中的异常 Exception
- B-spline Curves 学习之B样条曲线的系数计算与B样条曲线特例(6)
- IOS 之 NSURL的一些基本操作
- A few ways to tell Git which files to ignore.
- 设计模式C++版:第六式迭代器模式
- 浅谈IQKeyboardManager第三方库的使用
- MySql(17)------IF,CASE,LOOP,LEAVE,ITERATE,REPEAT,WHILE流程控制语句
- 基于以太坊的区块链浏览器搭建
- B-spline Curves 学习之B样条曲线的移动控制点、修改节点分析(7)
- Java设计模式——工厂设计模式
- 关闭CPU
- 根据网络图片的size大小设置UIImageView的大小