3

Some background: My company's service model began as an appliance-based server model. We would send our client a server with Windows Server 2003/2008 on it, pre-loaded with a webserver and our software. We're moving all of the client-specific configuration to a Git repository, and using sparse-checkout to make each server only contain what's necessary for the client's software to function properly.

While setting up sparse-checkout, we've run into a huge inconsistency. We'll do

git clone git@github.com:ourclientconfigrepo.git .
git config core.sparsecheckout true
echo www.thisclient.com/ > .git/info/sparse-checkout
git read-tree -m -u HEAD

The expected result would be

ls
www.thisclient.com/

but we get

ls
www.thisclient.com/
www.randomclient1.com/
www.randomclient2.com/
www.randomclient3.com/

I've tried multiple times, in a new directory each time, and the issue has happened each time. My ju-git-su fails me here. We're using git version 1.8.1.msysgit.1.

Thanks for your help, let me know if I need to supply more information.

---EDIT 1---

Clarification: The repository is nothing but our client's configuration directories. Each client has a different directory in the repository, and we're trying to sparse-checkout on each client's individual server, so we're trying to exclude everything except for the client in question.

---EDIT 2---

Just an update, turns out it was something wonky with Windows folder permissions, and Git was trying to delete non-empty directories. Fixed it by deleting the empty folders. Thanks for any and all attempts at helping!

V13Axel
  • 838
  • 5
  • 10
  • To clarify: they **are** directories. Maybe something weird with dots in the directory name....? That doesn't seem right, though. – Riking Mar 25 '13 at 15:55

2 Answers2

3

Your clone operation is not the correct way to create a sparse clone. Instead of:

git clone ...

You should use this sequence:

mkdir repo ; cd repo ; git init
git remote add -f origin <url>
git config core.sparsecheckout true
echo <dir1>/ >> .git/info/sparse-checkout
echo <dir2>/ >> .git/info/sparse-checkout
echo <dir3>/ >> .git/info/sparse-checkout
git pull origin master
Riking
  • 2,389
  • 1
  • 24
  • 36
0

A partial solution: According to git-read-tree(1), you can exclude specific files by putting a ! in front of the file name. This may be a miswrite, however (meaning that that's for directories as well, not files).

I'll continue investigating.

According to https://stackoverflow.com/a/11222033/1210278, you can manually mark directories with git update-index --skip-worktree www.randomclient1.com/.

https://stackoverflow.com/a/9575837/1210278 implies that exclusion is only for directories, and says that there are some bugs with it.

Community
  • 1
  • 1
Riking
  • 2,389
  • 1
  • 24
  • 36
  • Clarification: The repository is nothing but our client's configuration directories. Each client has a different directory in the repository, and we're trying to sparse-checkout on each client's individual server, so we're trying to exclude everything except for the client in question. – V13Axel Mar 25 '13 at 16:29
  • 1
    Turns out they were empty, but upvote for being the only one to attempt! – V13Axel Mar 27 '13 at 16:24
  • @AlexD Try putting a `.gitkeep` file in there (It has no actual purpose in Git except that it keeps the directory there) or a README file. – Riking Mar 28 '13 at 20:55