Created
November 8, 2015 12:40
-
-
Save varhub/abf5a6fab59061b1c6bc to your computer and use it in GitHub Desktop.
GIT by example: multiple gitignores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
varribas@Ubuntu14lts:/tmp/gitignore-test$ git --version | |
git version 1.9.1 | |
varribas@Ubuntu14lts:/tmp$ mkdir gitignore-test | |
varribas@Ubuntu14lts:/tmp$ cd gitignore-test/ | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git init . | |
Initialized empty Git repository in /tmp/gitignore-test/.git/ | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ mkdir -p a/b b c | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ touch a/A a/b/B b/B c/C | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git add . | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git status | |
En la rama master | |
Commit inicial | |
Cambios para hacer commit: | |
(use «git rm --cached <archivo>...« para eliminar stage) | |
new file: a/A | |
new file: a/b/B | |
new file: b/B | |
new file: c/C | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git rm --cached -r . | |
rm 'a/A' | |
rm 'a/b/B' | |
rm 'b/B' | |
rm 'c/C' | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ nano .gitignore | |
# ignoring 'b/' | |
# All 'b' directories will be ignored | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git add . | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git status | |
En la rama master | |
Commit inicial | |
Cambios para hacer commit: | |
(use «git rm --cached <archivo>...« para eliminar stage) | |
new file: .gitignore | |
new file: a/A | |
new file: c/C | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git rm --cached -r . | |
rm '.gitignore' | |
rm 'a/A' | |
rm 'c/C' | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ nano .gitignore | |
# ignoring '/b/' | |
# Only root 'b' directory will be ignored | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git add . | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git status | |
En la rama master | |
Commit inicial | |
Cambios para hacer commit: | |
(use «git rm --cached <archivo>...« para eliminar stage) | |
new file: .gitignore | |
new file: a/A | |
new file: a/b/B | |
new file: c/C | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git rm --cached -r . | |
rm '.gitignore' | |
rm 'a/A' | |
rm 'a/b/B' | |
rm 'c/C' | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ nano a/.gitignore | |
# ignoring '/A' | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git add . | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ git status | |
En la rama master | |
Commit inicial | |
Cambios para hacer commit: | |
(use «git rm --cached <archivo>...« para eliminar stage) | |
new file: .gitignore | |
new file: a/.gitignore | |
new file: a/b/B | |
new file: c/C | |
varribas@Ubuntu14lts:/tmp/gitignore-test$ | |
## Corolary: | |
# Git now accepts multiple .gitignore, one for each "sub-tree root" (= each directory) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment