Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slash prefix in gitignore #1384

Closed
dmpetrov opened this issue Nov 30, 2018 · 3 comments
Closed

Slash prefix in gitignore #1384

dmpetrov opened this issue Nov 30, 2018 · 3 comments
Labels
question I have a question?

Comments

@dmpetrov
Copy link
Member

$ dvc --version
0.21.2+22d38c.mod
$ mkdir so-dataset-posts
$ cd so-dataset-posts
$ git init
$ dvc init
$ git commit -m 'DVC init'
$ cp ../stackoverflow_small_xml/10K/Posts.xml.tgz .
$ dvc add Posts.xml.tgz
$ cat .gitignore
/Posts.xml.tgz

Why the file name has a slash prefix /?

@dmpetrov dmpetrov added the bug Did we break something? label Nov 30, 2018
@efiop
Copy link
Contributor

efiop commented Nov 30, 2018

Because without it the name is ambiguous and will match any file in any directory under the current one that is named Posts.xml.tgz, while we only need to ignore /Posts.xml.tgz(in the current directory).

@efiop efiop removed the bug Did we break something? label Nov 30, 2018
@efiop
Copy link
Contributor

efiop commented Nov 30, 2018

Here is an example:

#!/bin/bash

set -e
set -x

rm -rf myrepo
mkdir myrepo
cd myrepo
git init

mkdir dir
echo tracked > dir/tracked
git add dir
git commit -m "foo"

echo file > file
echo file > dir/file

echo file > .gitignore

git status

echo /file > .gitignore

git status
+ rm -rf myrepo
+ mkdir myrepo
+ cd myrepo
+ git init
Initialized empty Git repository in /storage/git/dvc/myrepo/.git/
+ mkdir dir
+ echo tracked
+ git add dir
+ git commit -m foo
[master (root-commit) 256f86a] foo
 1 file changed, 1 insertion(+)
 create mode 100644 dir/tracked
+ echo file
+ echo file
+ echo file
+ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore

nothing added to commit but untracked files present (use "git add" to track)
+ echo /file
+ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .gitignore
        dir/file

nothing added to commit but untracked files present (use "git add" to track)

@efiop efiop added the question I have a question? label Nov 30, 2018
@dmpetrov
Copy link
Member Author

Got it. Not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question I have a question?
Projects
None yet
Development

No branches or pull requests

2 participants