git - 如何做integrate the remote changes

浏览:29日期:2023-09-05

问题描述

git push origin master出现报错。

error: failed to push some refs to ’git+ssh://git@github.com/yufeiluo/newstart.git’hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., ’git pull ...’) before pushing again.hint: See the ’Note about fast-forwards’ in ’git push --help’ for details.

我这样解决了,git push -f origin master现在想用提示的方法解决You may want to first integrate the remote changeshint: (e.g., ’git pull ...’) before pushing again.如果全部git pull回来,那不就把本地的覆盖了?

我是新手,赐教

问题解答

回答1:

1.如果是本地分支和远程分支可以自动合并这个时候可以直接commit,然后push这样就可以了2.如果不一样就需要先git pull,但是这个命令会自动合并分支,可以使用git fetch,然后手动合并然后git push

回答2:

不建议直接使用git push -f,强制push可能会覆盖别人的修改,使用git pull并不会覆盖本地修改,如果可以merge到一起则会merge到一起,只要重新add/commit/push即可,如果有冲突的话,解决冲突就可以继续提交了。

相关文章: