开发者

Adding folders to a git repository while ignoring some subfolders

Im trying to add a directory "foo" to my repo, b开发者_StackOverflow社区ut there are some sub dirs lets call them "bar1", "bar2", "bar3" and "bar4"

Now I want to add foo to my repo, while ignoring foo/bar2 and foo/bar3

is this possible? do i need to add them first and then remove the folders I dont want?


Use .gitignore. Create a .gitignore file in your repository root that lists the files and folders you want ignored

foo/bar2/
foo/bar3/

You can use .gitignore files in subfolders as well if you don't want to specify everything from the root level.


If you want to always ignore subdirectories, then Andrews answer is what you want.

If you would like to add files from directory to index and ignore subdirectories for this one particular commit, then git add foo/ && git reset foo/bar2 foo/bar3 should work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜