问题
I have my github website deployed to a.github.io. Now, I have made some changes locally and want to push changes but I am unable to do so. This is what the settings of my repo says in the Github Pages section:
In my repo, I can see that the commits are being shown. However, the website is still not updated. If I run it locally, i see the changes but not on the actual website. Note that the original account where website it hosted is also different than the one through which I am making commits.
When I go to my local repo through terminal and run
git config --list
Instead of my username and email, I get two different emails of my two different accounts. The first user.name is basically my email for where I am hosting the website. The user.email is the email through which I am pushing changes.
user.name= ab@hotmail.com user.email=ab@gmail.com
This is how I am trying to update the website (the pushing worked last time but it's not even working rn):
git add *
git commit -m "added new picture"
Results:
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
deleted: favicon.ico
deleted: logo192.png
deleted: logo512.png
deleted: z<
no changes added to commit
git push
Result:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/aa
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first 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.
and then npm run deploy
回答1:
Try to pull first and then push.
git pull
Edit:
If there are merge conflicts after pulling you need to solve them before pushing again.
Warning: This is not recommended option, but if you are the only developer working you can use force for your commit. This will delete past commits, use it with caution.It can change history of other people on the same project.
git push -f origin master
来源:https://stackoverflow.com/questions/60528076/how-can-i-update-my-github-pages-website