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

Git推送至gh页面(更新被拒绝),git,deployment,github-pages,Git,Deployment,Github Pages,我有一个项目正在Github的一个gh pages分支中提供,它来自一个名为dist的文件夹。我知道如何从这个文件夹部署它,它一直很好,直到我尝试推出另一个版本 首先,我提交并推送到原始主机。 其次,我添加并提交dist文件夹 git add dist && git commit -m "Pasta dist adicionada ao projeto" 最后我试着推到gh页面 git subtree push --prefix dist origin gh-pages 下面

我有一个项目正在Github的一个gh pages分支中提供,它来自一个名为dist的文件夹。我知道如何从这个文件夹部署它,它一直很好,直到我尝试推出另一个版本

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

git add dist && git commit -m "Pasta dist adicionada ao projeto"
最后我试着推到gh页面

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.
那么…怎么了?

我找到了解决办法! 既然gh pages分支是一个可以删除的东西,那么我就这么做了。 在此之后,我只是再次推送到子树,因此重新创建gh pages分支并使用更新版本进行部署。 按照我需要的命令来完成它

$ git push origin --delete gh-pages
$ git subtree push --prefix dist origin gh-pages
我有办法了! 既然gh pages分支是一个可以删除的东西,那么我就这么做了。 在此之后,我只是再次推送到子树,因此重新创建gh pages分支并使用更新版本进行部署。 按照我需要的命令来完成它

$ git push origin --delete gh-pages
$ git subtree push --prefix dist origin gh-pages

谢谢,这是可行的,但是这样做意味着每次我删除并重新添加gh pages分支时,我必须手动设置哪个分支为Github.com上的Github pages站点服务。反复删除和重新添加gh pages分支,这样子树推送就好像不可持续了。谢谢,这是可行的,但是这样做意味着每次删除和重新添加gh pages分支时,我必须手动设置哪个分支为Github.com上的Github pages站点服务。反复删除和重新添加gh pages分支,这样子树推送就不可持续了。