Question

I'm moving our project from perforce to git. After a few setups and by the guide, I successfully created my git repo and imported source from perforce. Then I ran into problem that I can't simply import subsequent p4 changes to git repo. (Most of us are still working on perforce).

  1. git-p4 sync
  2. git push origin master

got following error

[rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:xxx/yyyyy.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I also tried

  1. git-p4 sync
  2. git-p4 rebase
  3. git pull
  4. git push

which worked finally. But I've no idea why.

The git-p4 sync manual said

After an initial import you can easily synchronize your git repository with newer changes from the Perforce depot by just calling git-p4 sync in your git repository. By default the "remotes/p4/master" branch is updated.

So I guessed that's why subsequent 'git push' didn't work. Do I have to rebase/pull/push every time? Do I miss something? I'm new to git, please help.

Était-ce utile?

La solution

If you are pushing code to a standard git repo, and it's rejected then you need to rebase your changes onto origin/master.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top