Search code examples
gitgit-remotegit-bare

Set up new bare repo (excluding few directories)


I want to create a new bare repo on the remote server that all team members can push to. Files with code already exist on the server. Let's say that there are 10 directories on the server but only 5 of them will be updated (commits will be made to).

The first step in my strategy is to, while on the server, mkdir repo.git, cd repo.git and then git init --bare --shared=group (all team members are in one group). The next step (applies to each of the team members' computers and is conducted on local machines) cd project, git init, git add ., git commit -m 'some message', git remote add teammember@server:/path/to/repo.git and finally git push origin master.

The next step is copying from the remote: git clone teammember@server:/path/to/repo.git and at this moment should I git add 5 directories that will be committed and then git commit -m 'message'. What about the other 5?


Solution

  • You can just leave the 5 directories alone. Git will only track the files that you add from the directories that you want. If you want to avoid anyone adding those directories on accident, you can add them to a file named .gitignore. You should add and commit this file to your repo.