search

Home  >  Q&A  >  body text

git submit issue

The submissions are all submitted on the master branch;

The project is developed by two parties. Because we often use each other's files, we do not plan to commit and modify the branch development on the main branch. Every time we submit the code, we use commands like git pull and then git add . git commit git push, but errors are often reported. , what version更新被拒绝,因为您当前分支的提示后面
Updates were rejected because the tip of your current branch is behind
what causes this;

天蓬老师天蓬老师2802 days ago681

reply all(6)I'll reply

  • PHPz

    PHPz2017-05-02 09:50:29

    For example, your online branch has two commits 1 and 2
    Your offline branch also has two commits 1 and 3
    At this time, after you pull the online branch, it may be 123 or 132 (use Google Baidu Rebase)
    If your online branch is 12 and your offline branch is 132 after pull, then there will be a conflict and lead to this situation (you can only add it at the end and not insert it in the middle)
    There is another situation where it is used amend At this time, although it seems that your online and offline submissions are the same (the commit message is the same), it is actually different (the commit id has changed), so git will think that there are two submissions. The changes in the two submissions overlap, causing conflicts.
    To solve this problem, you need to use push -f to force submission. Please search carefully and study the function of this command. We will not be responsible for any consequences

    reply
    0
  • 怪我咯

    怪我咯2017-05-02 09:50:29

    Have you ever submitted amend?

    reply
    0
  • 怪我咯

    怪我咯2017-05-02 09:50:29

    git pull --rebase (escape

    reply
    0
  • 黄舟

    黄舟2017-05-02 09:50:29

    After you pull the code to git pull, you should merge it with your local git rebase master and then push it

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-02 09:50:29

    First check the status git status, if it is red, just git add ., if there is a warning, force -A, add is followed by commit, commit and then pull to download. If there is a conflict after pull, resolve the conflict first and then start from add again, and finally push, at least that's how I do it Do it well and rarely go wrong. .

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:50:29

    Because the code has been submitted on the git remote repository, you cannot submit it directly. You must first synchronize the code of the remote repository to your local one before you can submit it. Generally, before submitting, you are accustomed to git pull --rebase

    reply
    0
  • Cancelreply