Search code examples
gitbitbucketgit-bare

How to pull updates from a remote (bare) master repo at Bitbucket to a local bare master repo?


First, a (bare) master repo with the name "test" is created in Bitbucket.

Then, a local bare master repo is created on a node with the ip 10.0.0.1:

git clone --bare https://[email protected]/username/test.git

Then, a local working repo is created on a node with the ip 10.0.0.253:

git clone ssh://[email protected]:/home/username2/test.git     

Thus, the work flow within 10.0.0.x is :

(1) code on 10.0.0.253 
(2) at 10.0.0.253, git push to 10.0.0.1
(3) at 10.0.0.1, git push to Bitbucket 

Suppose a local working repo is created outside 10.0.0.x, say 50.113.23.x, and directly from Bitbucket:

mkdir test
cd test
git clone https://[email protected]/username/test.git

The work flow there is :

(1) code on 50.113.23.x
(2) at 50.113.23.x, git push to Bitbucket 

Now, could you help to comment how to pull updates from the Bitbucket repo to the local bare master repo at 10.0.0.1 ? The following complains fatal: This operation must be run in a work tree:

git pull origin master

The following finishes, but a subsequent git log shows no commits from 50.113.23.x:

 git fetch origin master

Could you help to comment the workaround here ? Many thanks !


Solution

  • git fetch origin master:master
    

    I.e. explicitly update the local master.