Git add all subdirectories

前端 未结 7 1240
迷失自我
迷失自我 2020-12-23 10:59

I\'m having trouble adding a folder and all of it\'s subdirectories to my git repository. I realized this is a very popular question after doing some googling and I\'ve trie

相关标签:
7条回答
  • 2020-12-23 11:21

    I can't say for sure if this is the case, but what appeared to be a problem for me was having .gitignore files in some of the subdirectories. Again, I can't guarantee this, but everything worked after these were deleted.

    0 讨论(0)
  • 2020-12-23 11:23

    You can also face problems if a subdirectory itself is a git repository - ie .has a .git directory - check with ls -a.

    To remove go to the subdirectory and rm .git -rf.

    0 讨论(0)
  • 2020-12-23 11:23

    Also struggled, but got it right typing

    git add -f ./JS/*

    where JS was my folder name which contain sub folders and files

    0 讨论(0)
  • 2020-12-23 11:28

    Do,

    git add .
    

    while in the root of the repository. It will add everything. If you do git add *, it will only add the files * points to. The single dot refers to the directory.

    If your directory or file wasn't added to git index/repo after the above command, remember to check if it's marked as ignored by git in .gitignore file.

    0 讨论(0)
  • 2020-12-23 11:37

    I saw this problem before, when the (sub)folder I was trying to add had its name begin with "_Something_"

    I removed the underscores and it worked. Check to see if your folder has characters which may be causing problems.

    0 讨论(0)
  • 2020-12-23 11:44

    Simple solution:

    git rm --cached directory
    git add directory
    
    0 讨论(0)
提交回复
热议问题