git - 如何提交和/或添加未更改的文件?

标签 git github git-commit git-add

我有一个案例,我修改的文件没有显示为修改后的文件。

我还能提交那个文件吗?

我可以将列为未更改文件的文件添加到已更改文件吗?谢谢!

更新: 当我尝试添加文件时,终端出现这样的错误:

The following paths are ignored by one of your .gitignore files:
folderpath/filename.java
Use -f if you really want to add them.
fatal: no files added

但是当我打开我的 .gitignore 文件时:

bin
gen
#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated GUI files
*R.java

# Mac OS file
.DS_Store

信息/排除

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

我非常确定我的文件夹路径及其文件名未包含在 .gitignore 和排除文件中

最佳答案

git 不会跟踪未跟踪文件中的更改。

所以首先要确保你的文件确实被 git 跟踪了。其他人详细说明了为什么您的文件可能会被忽略(.gitignore.git/info/exclude、...)

然后确保您的文件确实包含更改(似乎很明显)。 你对文件做了什么样的改变? 请注意,您可以将 git 配置为忽略对 EOL 的更改,因此通过将 CRLF 更改为 LF 来修改文件不符合“要提交的更改”的条件。检查this .

关于git - 如何提交和/或添加未更改的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11790671/

相关文章:

git - 在 GIT 推送上接收电子邮件

git - 在 Git 分支之间切换,删除另一个分支中的文件

python - 将python flask web项目移动到github时如何隐藏数据库连接url?

git - 是否可以将 git commit 设置为具有 1970 年之前的时间戳?

Azure DevOps API : get latest action on the repository

git - merge 与我自己的冲突

Git 工作树 : two worktrees point in the same location, 无法修剪

git - 如何在wsl2网络驱动器下处理git

Git:测试两个功能分支的组合

git - 在github上追溯一个项目