How to ignore child git repositories, but not their contents

Viewed 100

I really need some help with Git. I have a code project. Inside of it i have a few directories that have their own git version tracking.

/root
----/folder1
----/folder2/.git
------------/file21
------------/file22
----/folder3/.git
------------/file31
------------/file32

Now i want to establish a process to backup the whole project to git server regularly. For this i init a git repository in root and add everything. I want literally everything to be backed up - all those files from git projects as well, no need to take their .git histories. My gitignore looks like this:

**/.git/

But those folders are still treated as git repos by my root git "backup" repo. Someone says that i need to use submodules, but i don't plan to maintain the rest of the project with version control. I just want to backup with that workflow and only use actual git power in those sub directories.

Could you please tell me how can i solve it? Thanks =)

2 Answers

The simplest way is to remove the .git folder in your subfolder.

The result of delete those .git folder is if the origin git repo updated those files, you will not not able to get the update by git command, instead you need to copy them into your own folder.

Submodule is a good suggestion. When you backup your root folder with submodels(which means folder2 and folder3 in your example), you can know what is your backup version by git hash version and if the remote changed.

You could use a command line tool called repo, it is used by aosp to manage hundreds of git submodules that are contained within the Android Open Source Project.

Related