title: creating git branch is extremely slow in large repository
body: <p>i have a local repository with ~300.000 files and about 40gb on an encrypted filesystem (and i cannot change that ...).
  i often need to create a new branch and make the current contents of the working directory the contents of this branch.</p>
  
  <p>so this "checkout" is not actually a checkout that modifies anything in the working tree, but just creates a branch, switches to it, and leaves the working directory unchanged.
  and it is <strong>not about large files</strong>: the average file size is much less than 1mb (40gb/300000=130kb)</p>
  
  <p>currently i do:</p>
  
  <pre><code>git checkout -q -b mynewbranch
  git add -v -A
  git commit -q -m "at mynewbranch"
  </code></pre>
  
  <p>in principle this works, but the first step to create the branch takes more than an hour (!).
  (the "add" and "commit" take a few minutes, i could live with that.)
  the "git checkout" seems to re-read the whole working directory just in order to create the branch.</p>
  
  <p>ideally i would want that creating the branch would take almost no time at all,
  and its state should simply be based on a previously existing branch.
  and then the "add" should also not take too much time since timestamps may be used
  and not all file contents should be compared to the repository,
  only files with new timestamps should be looked at in detail.</p>
  
  <p>has anybody an idea how this can be done efficiently ?</p>
  
  <p>edit: git 2.17, ubuntu, encfs over ext4, recent hardware, 12 cpu, mostly binary files (like pdf, jpeg, mp4; no deep tree; they need to be versioned).</p>
  
  <p>the primary issue is: can it be avoided that just creating a branch looks at the content of all files ?</p>