项目是两个开发,因为经常使用对方文件比较多,不打算分支开发在主分支提交和修改,我们每次提交代码 都是先git pull 然后git add . git commit git push这样的命令,但是经常报错,说什么版本更新被拒绝,因为您当前分支的提示后面 Updates were rejected because the tip of your current branch is behind 这样什么原因导致的;
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
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. .
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
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
Have you ever submitted amend?
git pull --rebase (escape
After you pull the code to git pull, you should merge it with your local git rebase master and then push it
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. .
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