Search code examples
gitbranchtagging

one git bare repository used for many clone


Is it possible to use the same git bare repository to hold data for different repositories? In other words, can I:

create a git bare repository (called BARE REPO)

clone it with master branch data from REMOTE REPO A

  • git clone -b consolidate --single-branch [email protected]:ConsolidateService.git
  • exec git add .
  • touch README.md
  • exec git commit -m "add README"
  • exec git remote add consolidate ssh://[email protected]/var/repos/app.makeatoy.git
  • exec git push consolidate master

erase the contents of BARE REPO

re-clone it with master branch data from REMOTE REPO B

  • git clone -b test --single-branch [email protected]:TestService.git
  • exec git add .
  • touch README.md
  • exec git commit -m "add README"
  • exec git remote add testing ssh://[email protected]/var/repos/app.makeatoy.git
  • exec git push testing master

erase the contents of BARE REPO

re-clone it with master branch data from REMOTE REPO C

  • git clone -b prod --single-branch [email protected]:ProdService.git
  • exec git add .
  • touch README.md
  • exec git commit -m "add README"
  • exec git remote add production ssh://[email protected]/var/repos/app.makeatoy.git
  • exec git push production master

If it is possible, how would one erase the contents of a bare repository?

TIA


Solution

  • create a bare repo and just add the remotes from different projects. To git, it's just unrelated branches. No need to delete anything after you fetch from each one (there's no working tree on a bare repo so nothing to delete.).