takeshin takeshin - 2 months ago 16
Git Question

git: stage only new files

When I have:


  • dirty working directory,

  • dirty staging area,

  • and I copied some new files to the project,



how do I stage only the new ones?

git alias adduntracked=…

Answer

This alias will respect your ignore patterns (builtin, global and per-directory, as described by the help for git-ls-files --exclude-standard). It will run at the top level of your tree.

[alias]
adduntracked=!git add $(git ls-files -o --exclude-standard)