search

Home  >  Q&A  >  body text

git 向远程仓库push的问题

一般在push的时候是不是都会先pull一下以保证代码最新,但是如果以下场景怎么办:

A:push,但是git提示过期于是进行pull,pull之后发现有冲突,然后merge
B:在Amerge的过程向服务器push了。
A:等他merge完,在push的时候服务器又变化了,再pull - merge
.....

这样会不会导致A一直没法push?

迷茫迷茫2809 days ago777

reply all(6)I'll reply

  • 巴扎黑

    巴扎黑2017-04-22 09:02:39

    The cause of the conflict generated during the first merge has been resolved locally. If the code pushed by others does not change this part, Merging again will go smoothly. Git will handle it automatically, so don't worry too much.

    If conflicts always occur during merge, it means that the code in the conflicting part is extremely unstable. Developers need to communicate with each other to solve it completely, or use some methods to bypass it.

    reply
    0
  • 高洛峰

    高洛峰2017-04-22 09:02:39

    After merging, it will be a new version. After pushing finds other versions, continue to merge another version.

    You can push it up one day.

    reply
    0
  • PHPz

    PHPz2017-04-22 09:02:39

    This problem should be solved in two ways: The first one: Only when the version difference is too large, you must pull + merge before you can push. But after you merge, if the version difference is not big, you can push. Second: Everyone should keep a branch of their own. First push to your own branch, and then merge from the server to the master.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-22 09:02:39

    A and B can discuss and reach an agreement, and they will only rebase but not merge. In this way, history looks better, with one line and no chaos.

    reply
    0
  • 怪我咯

    怪我咯2017-04-22 09:02:39

    If such a problem occurs, it means that the code coupling between A and B is too much and needs to be re-divided

    reply
    0
  • 迷茫

    迷茫2017-04-22 09:02:39

    Since there is a conflict, just merge. Keep merging until there is no conflict between him and you, then you can push it up

    reply
    0
  • Cancelreply