git fetch rebase pull

git fetch 

作用:将远程分支上的内容拉取到本地仓分支

git fetch origin 分支名

git fetch -p 拉取所有分支

git pull

是git fetch和git merge的合并

git push有时候会发生下方的报错:

git fetch rebase pull

 

测试

1.本地建立test分支与 远端first_version相关联

2.切换到first_version分支,提交内容(内容为first version)

3.然后切换到test1分支(此时提示test1分支落后于first_version分支)

4.此时时候git pull(相关与git fetch和git merge)

5.通过test1分支修改内容(内容为test version),然后push到远端first_version分支

git fetch rebase pull

test1分支的提交记录如下

git fetch rebase pull

此时我们再切换到first_version分支

6.若只执行git fetch命令,拉取远程first_version分支内容

7. 然后在first_version分支增加一次提交,进行push,此时会发生上面的报错

first_version的提交记录如下

git fetch rebase pull

通过提交记录我们可以知道,由于fetch命令是将某个远程主机的更新,全部取回本地,但是并没有与本地仓合并。所以会报behind的错误

此时需要将远端first_version仓库的内容合并到本地,才能push上去

使用git merge:

first version的提交记录如下

git fetch rebase pull

使用git rebase:

git fetch rebase pull

git rebase 和git merge区别 https://blog.csdn.net/qq8427003/article/details/64921010