Git推送到gh页(更新被拒绝)

时间:2018-08-30 00:38:43

标签: git deployment github-pages

我有一个项目正在Github的gh-pages分支中,从名为dist的文件夹提供服务。我想出了如何从该文件夹进行部署,直到我尝试推送另一个版本为止一切正常。

首先,我提交并推送到原始主机。 其次,我添加并提交dist文件夹

git add dist && git commit -m "Pasta dist adicionada ao projeto"

最后,我尝试推送至gh-pages

git subtree push --prefix dist origin gh-pages

这是所有日志过程:

samuel@debian:~/Documentos/01 - WEB/Cipher/web$ git add dist && git commit -m 

"Formulário para contato na página Contato.html"
[master 022dcf6] Formulário para contato na página Contato.html
 2 files changed, 2 insertions(+), 2 deletions(-)

samuel@debian:~/Documentos/01 - WEB/Cipher/web$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working tree clean

samuel@debian:~/Documentos/01 - WEB/Cipher/web$ git push
Enter passphrase for key '/home/samuel/.ssh/cipher-deploy': 
Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 452 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:samu101108/cipher-transcritor.git
   c2944ca..022dcf6  master -> master

samuel@debian:~/Documentos/01 - WEB/Cipher/web$ git add dist && git commit -m "Formulário para contato na página Contato.html"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

samuel@debian:~/Documentos/01 - WEB/Cipher/web$ git subtree push --prefix dist origin gh-pages
git push using:  origin gh-pages
Enter passphrase for key '/home/samuel/.ssh/cipher-deploy': 
To github.com:samu101108/cipher-transcritor.git
 ! [rejected]        4d627ffb7d871a68353d427d66a00fd917fe6639 -> gh-pages (non-fast-forward)
error: failed to push some refs to 'git@github.com:samu101108/cipher-transcritor.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

那...怎么了?

1 个答案:

答案 0 :(得分:2)

我找到了解决方案! 由于gh-pages分支是可以删除的东西,所以我做到了。 之后,我只是再次推送到子树,因此重新创建了gh-pages分支,并使用更新的版本。 遵循完成它所需的命令。

$ git push origin --delete gh-pages
$ git subtree push --prefix dist origin gh-pages
相关问题