git clone, ignoring file

git, github

Solution

2020+: use the more recent `git sparse-checkout` command (that I introduced here):

This will actually clone without downloading anything:

git clone --filter=blob:none --no-checkout https://github.com/git/git
cd git

I detail the exclusion here:

# Disablecone mode in .git/config.worktree
git config core.sparseCheckoutCone false

# remove .git\info\sparse-checkout
git sparse-checkout disable

# Add the expected pattern, to include just a subfolder without top files:
git sparse-checkout set !/your.exe

# populate working-tree with only the right files:
git read-tree -mu HEAD

2014: You can try a sparse checkout, which means:

- initializing an empty repo,

- add a remote pointing to the GitHub repo: `git remote add -f origin <url>`,

- `git config core.sparsecheckout true`,

- create a `.git/info/sparse-checkout` file in which you specify what you want to load.

In your case:

/*
!yourExe

You now can do a:

git pull origin master

That should download everything but your exe.

Problem

I want to clone a GitHub repo that has a giant .exe file in it. (why?!) I have zero use for the .exe file, and it is substantially bigger than everything else combined. Is there a way to ignore the file when I clone it? My guess is that I would have better luck asking the author to make an exe-less branch! Hopefully there is some nice way around this though.

Original source

Related problems