문제

I've got bonobo git server that's supposed to "handle syncing" among at least 2 machines, for now.

It was working fine but lately I've ran into one big problem with it and a related second one with git itself:

  1. I can't simply push from each client into it without getting the faded "non-fast-forward" issue, and though I believe it's an issue with bonobo and bare servers, its creator begs the differ, briefly.

    The following is not a copy paste, but it is the command I use when I get the issue and, as far as I recall, the warning should be very similar to this:

    git push -u "server"
    ! [rejected]        server/master     -> master  (non-fast-forward)
    
  2. Today I also can't even fetch from one client into another without getting the "non-fast-forward" freaking issue. Then I tried pushing from it into the server with the mirror option, which is the only one that works for pushing into the server due to issue #1, and pulling from the server on my machine. For my surprise, that worked! But now trying to fetch or pull from the other machine, the issue persists. My problem here is: why?!

    The following is just a copy & paste from Git Extensions:

    git fetch --progress "client" 
    Done
    From \\\CLIENT\project\git
    ! [rejected]        master     -> client/master  (non-fast-forward)
    

    I've actually fixed this using git fetch -f "client", but I still don't know what happened.

Disclaimer: Now I'm already going to git-scm.com to try and learn in details how the hell git works. Maybe I shouldn't even be trying to "fully sync everything" after all...

--

edit: Besides the obvious "not pulling before" issue, I've found two reasons why this could potentially be happening, but none helped fixing in my case: using rebase for editing past commits which are already replicated elsewhere or having same branches under different names, which must happen for the master at very least. This later one makes a lot of sense, except that it works some times and, after some pushes it stops working. Plus, on the fetch side, using fetch -f, it didn't broke any branches. So that wasn't it.

도움이 되었습니까?

해결책 2

As much as I have read resources around as I promised, I'm still far from being 100% confident dealing with every aspect of git. Still, I could finally find solutions for my issues here, and it's been stable for at least 1 month now.

For the 1st issue (non-fast-forward thing) I've found out 3 causes.

I'll mostly copy from bonobo forums:

  1. git commit --ammend

    I use this from time to time and I'm pretty sure if you push a commit then amend it and try to push it again, it will not be accepted. The only way I found around this issue is overwriting the push with the git push --mirror

  2. checkout older commits

    If there's a branch both local and in the server but my local branch is somewhere in the history before the same branch in the server, the push will fail. This has a simple solution: checkout the newest or newer commits than what's been pushed.

  3. conflicts

    As many said, merging. If the same branch (usually the master) is in different places because one machine pushed it to the server without merging first, then the other machine has to pull, merge and then it will be able to push just fine.

This 3rd point is where I think it gets really weird... In a bare repository, from what I understand, merging shouldn't be needed because it would not keep a consistency track of branches or tags, it'd just register where they are. Anyway...

For the 2nd issue it was most likely one of those 3 causes as well.

다른 팁

You need either to update client before pushing (git pull, for example) or use forced push (git push --force), but that case commits can be lost on the remote side and trigger non-fast-forward messages on other clients.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top