-1

I am trying to implement bare repository to sync two different repositories. I am following this post : https://softwareengineering.stackexchange.com/a/303201/102989

I am successfully able to sync both repo on first time but when I further commit something in Repo1(for e.g. master branch) and try to run same commands then it throw an error :

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

Please advise what I missed here

Thanks

Deepak.Aggrawal
  • 1,249
  • 11
  • 24

1 Answers1

0

One of the nice things about git is that its error messages are very explicit about what git thinks is going on and what git thinks you can do about it. Of course in rare cases, the authors may make bad assumptions about your intentions, but this is not one of those cases.

The error message says

error: failed to push some refs to 'https://UserName:Password@git. assembla.com/reponame.git'

Ok, so what's did you miss?

Updates were rejected because the tip of your current branch is behind its remote counterpart.

You can't (by default) push to a remote's branch that contains changes you don't yet have locally; you have to incorporate all of the changes already on the remote branch into your local branch before you can push it. This is necessary because it means merges always occur locally, giving the opportunity for conflict resolution.

So what can you do?

Integrate the remote changes (e.g. 'git pull ...')

You can run git pull. Or, equivalent but more clear (so sometimes recommended, especially for users less comfortable with git), you can

git fetch
git checkout master
git merge origin/master
Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52