I have a local directory in which I have initialized git. I have added all files of that directory in git using:
git add *
Now if I delete a file manually from my local directory, I want to get it deleted from github too. I have tried
git add -A *
But it does not work. Everytime I have to delete it manually from github too.
解决方案
The problem is that the glob (*) is expanded by your shell, not git, and the shell does not know anything about the files that you have already deleted. git add -A without any more arguments would add all the files, including deleted files. git add . will also do this in the current git version. You could also use git rm --cached for individual files as suggested in other answers.
It's usually easier to just use git rm to remove the files, as this will both remove the file AND stage the removal.
博主在本地目录初始化git并使用git add *添加所有文件,手动删除本地文件后希望同步到github,尝试git add -A *未成功。解决方案指出,可使用git add -A或git add.添加所有文件包括已删除文件,也可用git rm --cached处理单个文件,用git rm更方便,能同时删除文件并暂存删除操作。

被折叠的 条评论
为什么被折叠?



