I'm working on a basic Angular 5 project that I keep updated in the master branch on my github account. I recently added a live version of my project to github pages using the following tutorial: here where the following commands were run:
ng build
git add dist
git commit -m "checking in dist folder"
git subtree push --prefix=dist origin gh-pages
The above lines only pushed the contents of the /dist folder to the remote repo origin/gh-pages and this is where my live site (front-end) was loading from.
So after making changes and committing to my master branch in my local repo, I tried to sync the the origin/gh-pages branch as well (using a guide). But I receive the following errors and I have a feeling I'm doing (or did) something incorrectly. I'm quite new to Git and I don't understand the issue.
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git branch
* master
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git checkout gh-pages
Branch 'gh-pages' set up to track remote branch 'gh-pages' from 'origin'.
Switched to a new branch 'gh-pages'
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git rebase master
First, rewinding head to replay your work on top of it...
Applying: checking in dist folder
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git status
On branch gh-pages
Your branch and 'origin/gh-pages' have diverged,
and have 17 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git push
Username for 'https://github.com': ************
Password for 'https://***********@github.com':
To https://github.com/<github username>/address-book-angular.git
! [rejected] gh-pages -> gh-pages (non-fast-forward)
error: failed to push some refs to 'https://github.com/<github username>/address-book-angular.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.
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git pull
fatal: refusing to merge unrelated histories
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git rebase master
Current branch gh-pages is up to date.
lycan@lycan-dmini110 /media/lycan/Store4/WebDevelopment/Angular/SampleProjects/address-book-angular $ git push origin gh-pages
Username for 'https://github.com': <github username>
Password for 'https://<github username>@github.com':
To https://github.com/<github username>/address-book-angular.git
! [rejected] gh-pages -> gh-pages (non-fast-forward)
error: failed to push some refs to 'https://github.com/<github username>/address-book-angular.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.