Git remove directory

后端 未结 4 1577
天涯浪人
天涯浪人 2021-02-03 18:24

I\'ve got a repository on GitHub (http://github.com/hrickards/PHP-Crypto) for a little project me and a couple of others are working on. My development environment is Aptana Stu

相关标签:
4条回答
  • 2021-02-03 18:42

    The linked GitHub repository does not show the images directory.

    Git does not store empty directories for technical reasons, so just try rm images and remove the images directory from your local directory hierarchy.

    0 讨论(0)
  • 2021-02-03 18:48

    Git does not store any information about the directory, just the files within it. So, you cannot add or remove directories themselves; if you say git add images, Git will add all of the files within that directory (that don't match the ignore list).

    Generally, the only way for there to be an empty directory is if it actually contains a file, usually a hidden file like .gitignore.

    You said that you see an images directory on GitHub, but I'm not seeing it in the repo that you linked to. Are you sure it's there, and not just an empty directory on your disk? If it's just an empty directory on your disk, you can just remove it using rm images; Git doesn't need to know about it.

    0 讨论(0)
  • 2021-02-03 19:00

    This is what I use, and I think you'll want to as well. It's close to the other answers, but instructs git to NOT change the local files.

    git rm -r -f --cached DirectoryName
    
    • -r : recursive
    • -f : force
    • --cached : apply ONLY to index (staging area). Git leaves the local copies alone.
    0 讨论(0)
  • 2021-02-03 19:01

    try this:

    git rm -r -f DirectoryName
    
    0 讨论(0)
提交回复
热议问题