- Was trying to deploy my vue/vite project onto github pages and use a custom domain, but ran into some issues and messed things up by using git commands I didn't fully understand
- The deployed project worked before I tried adding a custom domain
- Followed instructions from the following video to deploy a vite project onto github pages: https://youtu.be/yo2bMGnIKE8
- Followed instructions from here to add custom namecheap domain: https://youtu.be/2K7asqt8wMw
- npm run build,
- git add dist -f
- git commit -m "adding dist"
- git subtree push --prefix dist origin gh-pages // [rejected] error: failed to push some refs to 'url', hint: Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (e.g.,) 'git pull ...') before pushing again.
- git pull
- git subtree push --prefix dist origin gh-pages // [rejected] error: failed to push some refs to 'url', hint: Updates were rejected because a pushed branch tip is behind its remote counterpart. Check out this branch and integrate the remote changes (e.g. 'git pull ...') before pushing again.
- git status: On branch main, Your branch is ahead of 'origin/main' by 11 commits. (use "git push" to publish your local commits)
- git push
- git status: Your branch is up to date with 'origin/main.'
- git subtree push --prefix dist origin gh-pages // [rejected] error: failed to push some refs to 'url', hint: Updates were rejected because a pushed branch tip is behind its remote counterpart. Check out this branch and integrate the remote changes (e.g. 'git pull ...') before pushing again.
- git pull origin main
- git pull origin gh-pages
- git pull --rebase origin gh-pages // lost all of my local files and reverted to initial project scaffolding from vue/vite
- Now I'm here panicking and still without a deployed project :)
link to github: https://github.com/AnthonyVNgo/LearnFS
Tried a bunch of git commands and followed the hint responses, but dug myself into a deeper hole.
CodePudding user response:
To recover lost work you can:
- Run
git reflog
- Find the entry that looks like it could have your lost work
- Run
git checkout the_id_shown_in_git_reflog
e.g.git checkout 100e500bd
. - Confirm that the lost work is found. If not, repeat
git reflow -> git checkout
until you find your work. git checkout -b my_lost_work
- create a branch with lost workgit push
- Relax. Now all your work is safely in github in a separate branch and you can start formulating a plan to fix your
main
andgh-pages
branches.
CodePudding user response:
Check if your work has been stashed away :
git stash show
git stash list