3

i can sync origin using

git fetch origin

i am on master branch, origin is a bare repo.

also i can run to push changes to github:

git push github  --all
git push github --tags

but why latest commits get using git fetch origin cannot be pushed to github?

when i push, git just replies with: Everything up-to-date

this means that push is in fact not happened :( since the latest commits fetched from origin is not pushed to github, why?

// this is local mirror of origin, and i want to push it to github

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[remote "origin"]
        fetch = +refs/*:refs/*
        mirror = true
        url = http://git.mirror.xxx.xx/xxx/root.git
[remote "github"]
        url = git@github.com:username/xxx.git
        fetch = +refs/heads/*:refs/remotes/github/*
thinke365
  • 1,215
  • 3
  • 14
  • 20

1 Answers1

2

git fetch will fetch all the remote tracking branches for origin.

But if those new commits don't concern your current local branch, git push github won't update anything regarding said (already up-to-date) current branch.
(depending on the current git push policy, and your git version)

You can try a git push --mirror github, in order to push all refs to GitHub.
But you will need first to fetch branches from github: git fetch github, in order for your local repo to know about said matching branches.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • how to know it that commits concerns my current local branch? why git push --all cannot push it? – thinke365 Sep 10 '12 at 11:40
  • 1
    @thinke365 `git push --all` will follow the default push policy (`matching`, until git2.0): if you don't have remote tracking branch for github remote repo, it won't push anything. `git push --mirror`, on the other hand, follows: "Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end" (http://git-scm.com/docs/git-push) – VonC Sep 10 '12 at 11:43
  • @thinke365 'git branch -a' will list all branches (remote tracking and local). – VonC Sep 10 '12 at 11:44
  • if you don't have remote tracking branch for github remote repo, what this means? – thinke365 Sep 14 '12 at 19:32
  • 1
    @thinke365 it means you might have to push those branches explicitly (http://stackoverflow.com/questions/1519006/git-how-to-create-remote-branch), or that you need to track them first: http://stackoverflow.com/a/6300386/6309 – VonC Sep 14 '12 at 20:25
  • @thinke365 by the way, make sure you aren't currently with a "detached `HEAD`" in your repo: http://stackoverflow.com/questions/12171261/cant-push-upstream-using-egit/12171567#12171567 – VonC Sep 14 '12 at 20:27