每当我尝试将rails应用程序推到heroku时,我都会出错。我该怎么解决这个问题?我做了git init、git add、git commit-m complete和git push heroku master

To https://git.heroku.com/shuabe.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/james.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

最佳答案

有人已经承诺,所以你必须更新你的brach-width git拉,以便最新。

git fetch --all --prune
git pull origin master

fetch将更新您的所有分支,pull将把最新内容捕获到您的主分支中。
如果你读了错误,它会解释你该怎么做。
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes

更详细
您正试图推送到一个远程分支,该分支有一些提交,而您的分支没有本地提交。要推送到non-fast-forward存储库,分支必须具有来自远程存储库的最新更新。
如何获取最新更新?
git fetch --all --prune

此命令将获取整个远程存储库的所有内容,并更新.git文件夹中的内部git存储(包和索引文件)。
git pull origin master

此命令将获取远程分支并将其合并到您的本地分支(master)中,然后您将能够推送更改。

08-27 18:23
查看更多