Why I couldn't commit a folder which I deleted accidentally in master in git?

时间:2019-04-17 02:45:41

标签: git

I accidentally deleted my folder named 'log' in the master. When I recreate that folder in my local and try to push that to master but git says 'everything is upto date' Why git is not allowing me to push the folder which I accidentally deleted in the master?

Rathas-MacBook-Pro:Dataloader ratha$ git add log/
Rathas-MacBook-Pro:Dataloader ratha$ git commit -m "log folder"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Rathas-MacBook-Pro:Dataloader ratha$ git push
Everything up-to-date

I tried git pull several times ten try to recraete a 'log' folder and trying to push that to master.But not working.

1 个答案:

答案 0 :(得分:0)

git不跟踪“文件夹”,仅跟踪“文件”。如果要“提交”文件夹,则需要先将一些文件放入其中。这样做的惯例是将一个名为.gitkeep的空文件放入其中,然后提交。

您可以使用git status来查看git告诉您有关工作目录的信息。如果仅创建一堆空文件夹,则git status。您会看到,git甚至都没有注意到它们的退出。只有在将真实文件放入文件夹后,git才能看到它们。

还要检查.gitignore配置文件中是否存在与“ log /”文件夹匹配的glob,这也可能是原因。