This question already has an answer here:
- git: stage only new files 8 answers
Is there a way to only add new files and not add modified files with git? That is, files that are listed as untracked with git status.
Other than ofcourse adding each file separately.
It's not absolutely necessary to do this in my case, the real question for me is answered here: How to make git-diff and git log ignore new and deleted files?
That is, don't show diff on new files, so I'm asking this more because i couldn't find an answer to it anywhere.
Maybe
git ls-files
lets you list the files managed by git, filtered by some options.-o
in this case filters it to only show "others (i.e. untracked files)"The
$(...)
statement passes the return value of that command as an argument togit add
.You can use short mode of git status (see man git-status(1)), which gives the following output:
Without short mode:
With short mode:
Then using grep, awk and xarg, you can add the files where the first column is
??
.and see that it worked: