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.
The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.
It does not add any new files, it only stages changes to already tracked files. git add -A is a handy shortcut for doing both of those.
So, if you run git add . within a sub directory, it won't add changes to files outside that sub directory. Second, git add . adds both tracked and untracked files.
Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.
Maybe
git add $(git ls-files -o --exclude-standard)
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 to git add
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With