今天在本地新建了个项目,在码云上也建了个仓库,想从本地推送到码云,但是git push -u origin master
,报错:
! [rejected] master -> master (fetch first)error: failed to push some refs to '/xxx/app.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 pull --rebase origin master
解决
rebase与merge区别:
rebase 会把你当前分支的 commit 放到公共分支的最后面,所以叫变基。merge 会把公共分支和你当前的commit 合并在一起,形成一个新的 commit 提交