andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

Homeshick tracked contents of a subdirectory despite its exclusion in .gitignore #130

Closed absorber closed 9 years ago

absorber commented 9 years ago

I have a ~/.maindir/ which I want to track, except for the contents of ~/.maindir/logs/.

For this reason, I have created a ~/.maindir/.gitignore file. In it, there's simply 1 line: logs/** (As per instructions of ProGit).

However, when I do homeshick track mydotfiles .maindir, it simply tracks the contents of ~/.maindir/logs/ despite my instructions in ~/.maindir/.gitignore.

andsens commented 9 years ago

The .gitignore should be part of the mydotfiles repository and not located in the folder in which you are trying to track files.

btw.: depending on globbing logs/** might not match hidden files (i.e. dotfiles), it'd be better to ignore /home/logs (the first slash means "start from the git project root").

absorber commented 9 years ago

Ah I see, but the problem still appears to be persisting.

I went ahead and made a directory and the gitignore file like so .homeshick/repos/mydotfiles/.maindir/.gitignore, with the contents being /home/.maindir/logs then in my ~ as cwd I issued homeshick track mydotfiles .maindir but it still decided to copy the logs subdir.

Is this intended behavior?

andsens commented 9 years ago

You should probably read up on how .gitignore works. The .gitignore needs to be at the root of the gitdir or at least in a parent directory of what you are trying to ignore. ...repos/mydotfiles/.maindir is wrong it should be ...repos/home/mydotfiles/.maindir, inside that you can place a .gitignore. I am not entirely certain whether the leading / actually means "from the git root" or "from the dir this gitfile is in".