Hello,
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=…
Hello,
When I have:
how do I stage only the new ones?
git alias adduntracked=…
I suggest something like this to copy:
for i in source/path ; do cp source/path/$i ./$i ; git add $i ; done
I'm not very well at shell scripting, but this would be an attempt
git add -u
is what I use to stage untracked.
Edit: comments below have reminded me that its git add .
that adds untracked (along with changed files, which I think is not what you want?). I use the git add -u
to stage deleted files.
If you want to add all untracked files to the staging area:
git add .
I suppose that you want this, while keeping the unstaged changes to tracked files outside of the index.
git stash
git add .
git stash apply
Would this help?
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)