gitpushgit-bashgit-bare

How to change git-bare repository location due to space issues?


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.


Solution

  • 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.