Category Archives: GIT

GIT – Clone a project to different server/remote

Change git repository URL in your project. E.g. config file in your project .git folder (myproj/.git/config) will look like



[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://myuser@github.com/myuser/myproj.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

Change project URL pointing to new server



[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://bitbucket.org/myuser/myproj.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

Push the project


$ git push --all origin

GIT – Push a project to multiple repository

Add following lines in file “.git/config” inside your project folder



[remote "all"]
        url = https://myuser@github.com/myuser/myproj.git myproj
        pushurl = https://bitbucket.org/myuser/myproj.git
        pushurl = ssh://mygitserver/myproj.git        

Then push the changes to all the repository


$git push all --all

GIT – Update submodules

As the project now uses a few git submodules, these will have to be installed after a fresh clone. To do so, execute the following command from project root directory:


$ git submodule update --init

Alternatively you can add –recursive to the clone command.


$ git clone --recursive https://myuser@github.com/myuser/myproj.git myproj

Pull all submodules attached with current project


$ git submodule foreach git pull origin master