0

I have a git-bare repository location under x:/Archivos Python/EPPTRA2.git/ and all the team is pulling and pushing changes from this repository. /x is a shared disk within our office network.

Not enough space

However recently I had to push many big files and found there isn't enough space.

$ git push
Counting objects: 1077, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1073/1073), done.
remote: fatal: write error: Not enough space
fatal: sha1 file '<stdout>' write error: Broken pipe
error: failed to push some refs to 'x:/Archivos Python/EPPTRA2.git/'

What I want to achieve

I would like to move the git-bare repository to another location, lets say /s/EPPTRA.git/ which is within other shared network disk with enough space. And then update my team mates' local repositories to ensure they point to the new git-bare repository location.

Questions

How can I change the git-bare repository location?

How can I push my last commit to the new git-bare repository location?

Which are the steps I need to do after so all my team mates point to the git-bare repository new location?

I'm looking for commands from git-bash in order to perform these tasks.

Cedric Zoppolo
  • 4,271
  • 6
  • 29
  • 59
  • May this [article](https://www.smashingmagazine.com/2014/05/moving-git-repository-new-server/) be part of the solution to my question? – Cedric Zoppolo Sep 18 '18 at 15:20
  • Possible duplicate of [Change Git repository directory location.](https://stackoverflow.com/questions/11384928/change-git-repository-directory-location) – phd Sep 18 '18 at 16:47
  • @phd the post you mention doesn't work with bare repositories. I believe this isn't a duplicate. I searched thoroughly for an answer and didn't find what I was looking for. – Cedric Zoppolo Sep 18 '18 at 17:01
  • When you move a repository as a directory there is no much difference between bare and non-bare repositories. – phd Sep 18 '18 at 17:04
  • I checked the size of a .git within a non-bare repository and a bare repository directory epptra2.git and they have different size. Also On the question you mention I didn't find how to change the remote origin location I need to change for all the team members (step 5 I stated on my own answer) – Cedric Zoppolo Sep 18 '18 at 17:06
  • Also the possible duplicated question doesn't answer with `git-bash` commands – Cedric Zoppolo Sep 18 '18 at 17:17
  • Moving directories (a repository is a directory) doesn't require `git-bash` commands. `git-bash` is required to fix remote URLs. – phd Sep 18 '18 at 19:12

1 Answers1

1

I believe I could achieve what I wanted correctly. I suppose there might be other ways.

Step 1: create new git-bare repository

First from the new location /s I created a bare repository:

$ cd /s
$ git init --bare EPPTRA2.git
Initialized empty Git repository in S:/EPPTRA2.git/

Step 2: mirror a non-bare repository to the new git-bare repository

Afterwards I went to a non-bare repository, which hadn't my last commits, and mirrored the repository to the bare repository (I actually had a reposirtory under /s/epptra2 which was non-bare and could use that one):

$ cd /s/epptra2
$ git push --mirror /s/epptra2.git
Counting objects: 22412, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7300/7300), done.
Writing objects: 100% (22412/22412), 1.68 GiB | 1.96 MiB/s, done.
Total 22412 (delta 17271), reused 19487 (delta 15075)

Step 3: Change remote origin location

Then I had to remove the previous origin and create a new one:

$ cd /d/epptra2
$ git remote rm origin
$ git remote add origin /s/epptra2.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
$ git branch -u origin/master

Step 4: Push commited changes to new bare-repository

And finally I pushed the commits I had done from my local repository:

$ git push
Counting objects: 1077, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1073/1073), done.
Writing objects: 100% (1077/1077), 4.53 GiB | 922.00 KiB/s, done.
Total 1077 (delta 441), reused 0 (delta 0)
To S:/epptra2.git
   da05677..d1c8610  master -> master

Step 5: update all local repositories' remote origin

For my team mates' local repositories I had to repeat step 3 and then perform a git pull to ensure everything was working properly.

Note: /d is a local disk in my PC, and /s and /x are network mounted drives.

Cedric Zoppolo
  • 4,271
  • 6
  • 29
  • 59