问题:
I ran "git status" and listed below are some files that were modified/or under the heading "changes not staged for commit". 我运行了“git status”,下面列出了一些被修改的文件/或标题为“未提交更改的更改”标题。 It also listed some untracked files that I want to ignore (I have a ".gitignore" file in these directories). 它还列出了一些我想忽略的未跟踪文件(我在这些目录中有一个“.gitignore”文件)。
I want to put the modified files in staging so I can commit them. 我想将修改后的文件放在暂存中,以便我可以提交它们。 When I ran "git add .", it added the modified files AND the files I want to ignore to staging. 当我运行“git add。”时,它将修改后的文件和我想忽略的文件添加到登台。
How do I add only the modified files and ignore the untracked files if presented with the git status below. 如果使用下面的git状态显示,如何仅添加已修改的文件并忽略未跟踪的文件。
Also, are my ".gitignore" files working properly? 另外,我的“.gitignore”文件是否正常工作?
$ git status
# On branch addLocation
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: someProject/path/domain/viewer/LocationDO.java
# modified: someProject/path/service/ld/LdService.java
# modified: someProject/path/service/ld/LdServiceImpl.java
# modified: someProject/path/web/jsf/viewer/LocationFormAction.java
# modified: someProject/war/WEB-INF/classes/message/viewer/viewer.properties
# modified: someProject/war/page/viewer/searchForm.xhtml
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# .metadata/
# someProject/build/
no changes added to commit (use "git add" and/or "git commit -a")
解决方案:参考一:
https://stackoom.com/question/TtSw/git只添加修改后的更改并忽略未跟踪的文件
参考二:
https://oldbug.net/q/TtSw/git-add-only-modified-changes-and-ignore-untracked-files