GithubHelp home page GithubHelp logo

spacecase123 / git-ignore-command Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nemec/git-ignore-command

0.0 0.0 0.0 5 KB

A custom command for git to manage the gitignore file (with help from gitignore.io)

License: MIT License

Python 100.00%

git-ignore-command's Introduction

git-ignore-command

A custom command for git to manage the gitignore file (with help from gitignore.io)

Installation

Copy the file git-ignore somewhere on your PATH so that it can be found by git.

NOTE: this application has only been tested on Linux, although I have tried to make it as cross-platform as possible. I am not sure if git on Windows will be able to execute Python files with a shebang (#!/usr/bin/env python3) in custom commands.

cp git-ignore ~/.local/bin/ && chmod +x ~/.local/bin/git-ignore

Test

To ensure the command installed properly, run the following. If properly installed, a list of all languages supported by gitignore.io will be displayed in the terminal.

git ignore --list

Usage

Find the path of .gitignore file

This command will display the absolute path to the .gitignore file that applies to the top level git repository in your current directory or a parent. If you are in a submodule, it will find the .gitignore file of the parent module.

If this command is run outside of a git repository or a .gitignore file does not exist, it will display nothing.

git ignore --find

Example output:

/home/me/prg/.gitignore

List all available languages

This command will display a list, one per line, of all available languages that have .gitignore templates on gitignore.io.

This command can be run outside of a git repository.

git ignore --list

Example output:

1c
1c-bitrix
a-frame
actionscript
...

Display templates for a selection of languages

This command will query for a template from gitignore.io and print it to the terminal. After --list put all of the languages you want in the template. Your existing gitignore, if any, will not be modified.

This command can be run outside of a git repository.

git ignore --list c++ python

Example output:

# Created by https://www.gitignore.io/api/c++
# Edit at https://www.gitignore.io/?templates=c++

### C++ ###
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
...

Append a template for a language to your gitignore file

This command will query gitignore.io for one (or more) languages and append the resulting template to your gitignore file. The .gitignore file applies to the top level git repository in your current directory or a parent. If you are in a submodule, it will find the .gitignore file of the parent module.

If no .gitignore file exists, one will be created in the root of your top level repository and named .gitignore.

The program will attempt to de-duplicate byte-identical directives that are in the existing .gitignore file (if available). It cannot detect directives that are slightly different (e.g. whitespace) but otherwise semantically identical to an existing directive. It tries to keep comments/errors and is not idempotent if the same languages are appended multiple times.

NOTE: Since directives later in the file take priority over conflicting directives earlier in the file, there is a chance that partially-de-duped directives may end up out of the expected order. When dealing with a complex .gitignore, it is recommended to double check the whole file and make sure it still is sensible.

git ignore -a c++ python

If you wish to override the default destination of the gitignore file when appending, add the argument -f or --file. This argument removes the need to run the command from within a git repository.

git ignore -a code -f ~/prg/py/.gitignore

Display the contents of the gitignore file in the terminal

This is generally a shortcut equivalent to cating the result of git ignore --find.

git ignore

If you wish to override the default destination of the gitignore file when appending, add the argument -f or --file. This argument removes the need to run the command from within a git repository.

git ignore -f ~/prg/py/.gitignore

git-ignore-command's People

Contributors

nemec avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.