Adding git-ignore command, tests, and documentation.
Subsystems (2)
cover Adding git-ignore command, tests, and documentation.
git-ignore will allow users to quickly add entries to the gitignore files in the repositories.
Many times, I'll have a config file or log file buried in a series of sub-directories and find it frustrating to edit the right git ignore with the right relative path to the file that i want to add. This script makes adding items to a gitignore file easier.
Instead of managing paths and relative paths such as echo "path/to/the/file.txt" >../../../../../../.gitignore git ignore path/to/the/file.txt No matter what directory that is in, the correct relative path will be added to the gitignore.
This script will also give the ability to add directories, extention globs, and files to any gitignore in parent directories. Furthermore, it allows you to easily open the gitignore file in your favorite editor from anywhere
using: git ignore --edit
I have been using this script for years and it has made things much easier for me, so I figured I'd contribute.
Thurston Stone (1):
Adding git ignore command
.gitignore | 1 + Documentation/git-ignore.txt | 116 ++++++++++++++++++ Makefile | 1 + git-ignore.sh | 222 +++++++++++++++++++++++++++++++++++ t/t7070-ignore.sh | 180 ++++++++++++++++++++++++++++ 5 files changed, 520 insertions(+) create mode 100644 Documentation/git-ignore.txt create mode 100755 git-ignore.sh create mode 100755 t/t7070-ignore.sh
base-commit: 8dca754b1e874719a732bc9ab7b0e14b21b1bc10
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-264%2Ftstone2077%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-264/tstone2077/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/264
Signature · 1 line
gitgitgadget
PATCH 1/1 Adding git ignore command
From: Thurston Stone <[email protected]>
The 'git ignore' command modifies a .gitignore file in your path easily. By default, it adds lines to the .gitignore found in the root of your repository. It can, however, add lines to a gitignore anywhere inbetween the file(s) passed in and the root of the repository. The lines added to the gitignore can be based on filename, extension, directory, or recursive glob.
Also, you can easily open the gitignore file using your $EDITOR with 'git ignore --edit'.
This can make things much easier when ignore files in subdirectories. No longer will you have to run:
echo "path/to/the/file.txt" >../../../../../../.gitignore instead:
git ignore file.txt
--- .gitignore | 1 + Documentation/git-ignore.txt | 116 ++++++++++++++++++ Makefile | 1 + git-ignore.sh | 222 +++++++++++++++++++++++++++++++++++ t/t7070-ignore.sh | 180 ++++++++++++++++++++++++++++ 5 files changed, 520 insertions(+) create mode 100644 Documentation/git-ignore.txt create mode 100755 git-ignore.sh create mode 100755 t/t7070-ignore.sh
.gitignore +1 -0
@@ -76,6 +76,7 @@ /git-http-backend /git-http-fetch /git-http-push +/git-ignore /git-imap-send /git-index-pack /git-init
Documentation/git-ignore.txt new file +116 -0
116 lines not on this page · raw message
Makefile +1 -0
@@ -606,6 +606,7 @@ TEST_PROGRAMS_NEED_X = unexport CDPATH SCRIPT_SH += git-bisect.sh +SCRIPT_SH += git-ignore.sh SCRIPT_SH += git-difftool--helper.sh SCRIPT_SH += git-filter-branch.sh SCRIPT_SH += git-merge-octopus.sh
git-ignore.sh new file +222 -0
222 lines not on this page · raw message
t/t7070-ignore.sh new file +180 -0
180 lines not on this page · raw message
Signature · 1 line
gitgitgadget
Quoted 4 lines · Thurston via GitGitGadget
Instead of managing paths and relative paths such as echo "
path/to/the/file.txt" >../../../../../../.gitignore git ignorepath/to/the/file.txtNo matter what directory that is in, the correct relative path will be added to the gitignore.
Hmph, do you mean you type something like this?
$ cd path/to/the ... work in that deep directory ... ... realize that file.txt in that directory needs ignoring ... $ echo path/to/the/file.txt >../../../../../../.gitignore
Wouldn't this simpler to type and less error prone, as you do not have to count ../?
$ cd path/to/the ... work in that deep directory ... ... realize that file.txt in that directory needs ignoring ... $ echo file.txt >.gitignore
Quoted 14 lines · Junio C Hamano
Quoted 4 lines · Thurston via GitGitGadget
Instead of managing paths and relative paths such as echo "
path/to/the/file.txt" >../../../../../../.gitignore git ignorepath/to/the/file.txtNo matter what directory that is in, the correct relative path will be added to the gitignore.Hmph, do you mean you type something like this?
$ cd path/to/the ... work in that deep directory ... ... realize that file.txt in that directory needs ignoring ... $ echo path/to/the/file.txt >../../../../../../.gitignore
Quoted 7 lines
Wouldn't this simpler to type and less error prone, as you do not have to count ../?
$ cd path/to/the ... work in that deep directory ... ... realize that file.txt in that directory needs ignoring ... $ echo file.txt >.gitignore
It's also much more efficient, at least with our current implementation, as we do not have to worry about matching this entry when we are dealing with /some/other/path. See [1] for a pathological case.
I see "with our current implementation" because I could imagine a world in which we have a more trie-like structure for non-wildcard patterns. But I don't think anybody is working on such a thing.
-Peff