Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use .gitignore to ignore files in the Git repository

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to use .gitignore to ignore files in the Git warehouse". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

.gitignore

In Git, many times you just want to submit the code to the repository, rather than submitting all the files in the current file directory to the Git repository, such as the. DS_Store file under the MacOS system, or the operation record of Xocde, or a large string of source code in the pod library. Using .gitignore in this case can automatically ignore these files when Git commits.

Ignored format

#: this is a comment-will be ignored by Git

* .a: ignore all files ending with .a

! lib.a: do not ignore lib.a files

/ TODO: only ignore the TODO file in the project root directory, not including subdir/TODO

Build/: ignore all files in the build/ directory

Doc/*.txt: ignores doc/notes.txt but does not include doc/server/arch.txt

The creation method is obtained from the github

Github collates the file configurations that need to be ignored in some commonly needed projects, and obtain them as needed.

Https://github.com/github/gitignore.git

Three files related to Xcode

Xcode.gitignore

Objective-C.gitignore

Swift.gitignore

Xcode.gitignore ignores Xcode configuration information, such as operation records, opening windows by default, etc.

The other two ignore different languages on the basis of Xcode.gitignore.

Rewrite these files as .gittignore

$mv Swift.gitignore .gittignore created through gitignore.io (recommended)

Customize the terminal command first:

The default is\ #! / bin/bash under macOS:

$echo "function gi () {curl-L-s https://www.gitignore.io/api/\$@;}" > > ~ / .bash_profile & & source ~ / .bash_profile

If it is #! / bin/zsh

$echo "function gi () {curl-L-s https://www.gitignore.io/api/\$@;}" > > ~ / .zshrc & & source ~ / .zshrc

Use

Under the current terminal directory

$gi swift > .gitignore

A .gitignore file is created for projects of type Swifit.

That's all for "how to use .gitignore to ignore files in the Git repository". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report