search

Home  >  Q&A  >  body text

[git] If someone else pushes first when pushing, do I need to roll back all my local submissions?

Bi Fang said
I pulled the code from the server at 11:00, then merged it with my local one and submitted it. When I was preparing to push at 11:01, it prompted me before I pushed. Someone else has already rushed to push, and I need to pull again before submitting. Do I need to roll back my local commit at this time?

If I need to roll back my local commit, how should I roll it back?

What I do now is git reset --hard commitid. This seems to move the files I submitted out of the temporary storage area? Am I doing the right thing? Are there any other ways to do this?

为情所困为情所困2769 days ago654

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-05-02 09:28:53

    Should we pull again?
    If there is a conflict, resolve the conflict and then commit and push
    If there is no conflict, commit and push directly

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:28:53

    After git pull down,

    1. If there is a conflict, resolve the conflict before committing, and then push;

    2. If there is no conflict, you can push directly

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-02 09:28:53

    After you pull from the server, you actually merge the previous rescue push into your own local version. There are two results:

    1. Automatic merge successful (fast-forward)

    2. Automatic merge failed, manual merge is required

    In both cases, you should re-run test to ensure that the merged code does not affect your original functions and ideas. Then push.

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-02 09:28:53

    git fetch origin && git rebase origin/master && git push

    reply
    0
  • Cancelreply