无法强制 Git 添加
我在 ~/bin 处获得 git-status:
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# screen/dev/
我运行后
git add --force screen/dev/
得到与以前相同的 git-status。 我独立地添加文件夹中的每个文件,但我得到相同的 git-status。
screen/dev/ 中没有 .git。 该文件夹似乎不是一个 sumbodule。
如何将文件夹及其内容强制添加到我的 git ~/bin 中?
I get git-status at ~/bin:
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# screen/dev/
I run
git add --force screen/dev/
I get the same git-status as before. I add each file in the folder independently, but I get the same git-status.
There is no .git in screen/dev/. The folder seems not to be a sumbodule.
How can you add a folder and its content with force to my git at ~/bin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您不需要“
--force
”或“-f
”选项:请参阅git add:-f
--force
:允许添加忽略文件。
在您的情况下,您可能不想添加所有文件,包括 screen/dev 目录下被忽略的文件。
应该足够了(没有选项或以“/”结尾)
You should not need '
--force
' or '-f
' option: see git add:-f
--force
:Allow adding otherwise ignored files.
In your case, you may not want to add all files, included ignored files under screen/dev directory.
should be enough (without options or ending '/')
可以通过重命名文件夹并将新名称的文件夹添加到 Git 中来解决该问题。
这表明一定有某个文件在操作文件夹名称
dev
。The problem can be solved by renaming the folder and adding the folder with a new name to Git.
This suggests me that there must be some file manipulating the folder name
dev
.这是剪切粘贴上的错字吗?
如果不是的话,应该是
Is that a typo on cut paste?
If not, it should be
尝试这样做:
另外,如果您有 .gitignore 文件,您也可能无意中忽略了某些内容(即:可能是您尝试添加的文件)。
Try doing:
Also, if you have a .gitignore file it's also possible that you are unintentionally ignoring something (ie: possibly the files you are trying to add).
如果没有任何效果...
git add -A
If nothing works...
git add -A
我还发现你必须在该目录中至少有一个文件才能被 git 拾取。 如果里面没有文件,
git add screen/dev
将不起作用。I've also found that you have to have at least a file in that dir in order to be picked up by git.
git add screen/dev
won't work if there are no files inside.只需 git add 。
休息一下
有一个奇巧
泡杯咖啡
,过一会儿你回来时就应该完成了
Just git add .
Take a break
Have a KitKat
Make a cup of coffee
and when you come back after a while it should be done