Halsafar
Halsafar

Reputation: 2640

GIT Branch Work Flow

Working in a large group project this is our work flow:

 // create branch
 git checkout -b mybranch
 (do work)
 // commit to branch locally
 git commit -a
 // push to remote
 git push origin mybranch
 (repeat)

When done with working in our branch we merge the branch into master:

 // go to master
 git checkout master     
 // update
 git pull master
 // merge our branch into master
 git merge mybranch
 (solve conflicts)
 git push

Now we just repeat the above steps and work flow was fine for a few days. Now suddenly everyone is getting non-forward updates on other group members branches and master. For example someone git pulled within master, then merged but they cannot push. It says non-fast-forward push. This is very odd as it says master is completely up to date.

The following is immediately after a git pull, git merge mybranch, git push:

  ! [rejected]        master -> master (non-fast-forward)
  error: failed to push some refs to '[email protected]:foo/project.git'
  To prevent you from losing history, non-fast-forward updates were rejected
  Merge the remote changes (e.g. 'git pull') before pushing again.  See the
  'Note about fast-forwards' section of 'git push --help' for details.

Yet a git pull says we are up to date.

So the question is, what is the expected workflow for a large group within GIT? How should we be dealing with the branching mechanism.

Thanks!

Upvotes: 2

Views: 261

Answers (1)

Borealid
Borealid

Reputation: 98459

There was no problem with your previous workflow.

You pull in new changes, merge your branches together, and then push out the merged result. At your option, you may use rebase instead of merge for changes which were never made public.

The issue here is likely that someone rewrote history in their local copy; if that happens, you'll be "up to date" - as in, your working copy is identical to the remote end - but you won't be able to push.

If you do a fresh clone of the repository, and from there do a merge and push, it will probably succeed.

Upvotes: 3

Related Questions