0

I like to reset my local repository to catch up with the remote repository HEAD. From Reset local repository branch to be just like remote repository HEAD and other sites, I can see the normal command set is:

git fetch origin
git reset --hard origin/master

However, that's still not enough for me. What else can I check/should I do?

Long story, similar with Merge remote repository commits to the local, I have two local repositories say A and B. B was created from A just by copying files, well in fact, both A and B are in VM and the VM for B was duplicated from A. Both repositories A and B have the same remote git repository.

The repository B lives his life - are added some patches, updated spec files, etc, while repository A stays at the point of VM duplication. Now I want to bring my local repository A up to where B is, via their common remote git repository. So I tried git pull first, but get Already up-to-date.. Then I did the above two commands, i.e.,

$ git fetch origin

$ git reset --hard origin/master
HEAD is now at 49e7629 - ...

at repository A. However, that 49e7629 HEAD is still old, comparing to repository B.

The git log shows that repository B still have more updated than repository A. What else can I check/should I do?

Has it anything to do with how my remote git repository is configured? Here is my remote git repository:

$ cat .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = ssh://git@bitbucket.org/myid/myrepo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

Thanks

Community
  • 1
  • 1
xpt
  • 20,363
  • 37
  • 127
  • 216

2 Answers2

0

What I understand is : A and B are clones of the same distant remote repository (named origin) You want to update A with B changes

A solution for that case would be: Place yourself in A and then, add B as a remote:

git remote add originB /path/to/B/repository

You can now list your remotes:

git remote -v

Which should print:

origin ssh://git@bitbucket.org/myid/myrepo.git (fetch)
origin ssh://git@bitbucket.org/myid/myrepo.git (push)
originB /path/to/B/repository (fetch)
originB /path/to/B/repository (fetch)

Now you can fetch/merge/... from originB, following the right syntax. For an example:

git pull originB anybranch

You will find more infos at http://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes

Romain
  • 186
  • 1
  • 7
0

Changes in Repo B need to be pushed to the shared remote in order for Repo A to pull them. Otherwise the changes in B are local only to B.

Schleis
  • 41,516
  • 7
  • 68
  • 87
  • Duh! I was so focused on the `nothing added to commit` from the `git status` output, that I completely blindside to the fact `Your branch is ahead of 'origin/master' by 4 commits.` Thanks! – xpt Nov 04 '14 at 20:11