Closed metasean closed 10 years ago
I think the problem is related to the directory's remote being incorrectly set to origin
instead of github
.
I think this because @jr0cket suggested that someone else run git remote -v
(he had them do it in the .deploy directory, I did mine in the parent directory which is where the .git file is normally stored; https://github.com/hexojs/hexo/issues/648#issuecomment-45061436). My results are:
origin https://github.com/metasean/metasean.github.io.git (fetch)
origin https://github.com/metasean/metasean.github.io.git (push)
But according to his post, my results should be something like this:
github git@github.com:metasean/metasean.github.io.git (fetch)
github git@github.com:metasean/metasean.github.io.git (push)
So how do I 'fix' my .git file? Or is this indicative of another problem?
just a quick fix of your git problem (don't know if it helps with your deploy problem)
git remote add github git@github.com:metasean/metasean.github.io.git
This will add another remote repo, as you can verify with git remote -v. origin will still be there. you could delete it with git remote remove origin, but you should not.
This is a silly question, but did you do hexo generate
before doing hexo deploy
. It may not be the cause of your problem, so lets investigate a little
Unless you are versioning your hexo project (I version my hexo project), then you would only have a .git
directory in your .deploy directory.
To version your hexo project you would have:
metasean.github.io/.git
To deploy the static content created by hexo generate
and then hexo deploy
, you would have the directory structure
metasean.github.io/.deploy/.git
When you run hexo deploy
for the first time in a new hexo project (in the folder metasean.github.io
), it will create the .deploy
directory and links the local repository in there to the repository on github. When I ran hexo deploy
the remote repository alias github
was used rather than origin.
I suspect that the following output for the git remote -v
command refers to the repository you are using to version your project, rather than the remote repository used to deploy your static content via the hexo deploy
command
origin https://github.com/metasean/metasean.github.io.git (fetch)
origin https://github.com/metasean/metasean.github.io.git (push)
I suspect this because your _config.yml
file has the URL in the form of git@github.com:metasean/metasean.github.io.git
where as the above result of git remote -v
is using the https form of the URL.
Please confirm
1) You have a .deploy
directory which contains a .git
directory
2) The output of the git remote -v
command from within the metasean.github.io/.deploy
directory
3) That you are running the command in order hexo init metasean.github.io
, cd metasean.github.io
, edit the _config.yml to add the github configuration, hexo generate
, hexo deploy
.
At no point should you need to run git init
or git clone origin https://github.com/metasean/metasean.github.io.git
in order to deploy your static content.
If you have 2 factor authentication switched on in your Github account as I do, you may need to do the following:
"I am using two-factor authorisation with Git which seems to cause an authentication problem. To fix this I run hexo deploy to create the .deploy directory and put its contents under Git version control. Then I change into the .deploy directory and do a manual push to Github with the command git push github master. From then on hexo deploy works correctly."
See my article on pushing to Github pages for more context around the above issue
I hope this makes sense. If not, please specify where I have not explained myself well enough.
Thanks @jr0cket
@jkuetemeier & @jr0cket - First off, thank you both for responding so quickly!
@jkuetemeier - I knew there was a command, but I wasn't sure what it was. That looks right. At this point, if hexo deploy
is supposed to handle it (which I thought it was, and from @jr0cket's comments, I still believe it is) then, if possible, I want to get my hexo deploy
working. If I can't, I will absolutely resort to making my own git pushes, in which case your info will absolutely be vital!
@jr0cket - think some of my previous problems and anomalies were actually because of my previous attempts. I have been using Sublime to edit my files. I open the entire working directory in Sublime. I believe Sublime was somehow 'fixing' content for me after I deleted and recreated my working directory. I had a file with a pretty unique name (i.e. the file is definitely not created during the hexo init
process) that I had created on a previous attempt that I noticed in my working directory this morning. So, I closed my Sublime windows, deleted my github repo, and local directory, and started afresh, again.
Here's what I've done (sans early morning typos: git deploy
& hexo clear
) in order and with explanatory comments where appropriate :
Terminal:
hexo init metasean.github.io
cd metasean.github.io
npm install
_config.yml
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: github
repo: git@github.com:metasean/metasean.github.io.git
branch: [branch]
message: [message]
Terminal:
git remote -v
Result (expected based on your comments):
fatal: Not a git repository (or any parent up to mount point /Volumes/Macintosh HD)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
_config.yml
repo: https://github.com/metasean/metasean.github.io.git
Terminal:
git remote -v
Result (also expected based on your comments; just wanted to verify):
fatal: Not a git repository (or any parent up to mount point /Volumes/Macintosh HD)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Terminal (I had not done this on my previous attempt):
hexo generate
git remote -v
Result (again, expected):
fatal: Not a git repository (or any parent up to mount point /Volumes/Macintosh HD)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Terminal:
hexo deploy
Result:
[info] Start deploying: github
[info] Setting up GitHub deployment...
Initialized empty Git repository in /Volumes/Macintosh HD/Users/seanduncan/projects/metasean.github.io/.deploy/.git/
[master (root-commit) a43b5ce] First commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 placeholder
[info] Clearing .deploy folder...
[info] Copying files from public folder...
[error] TypeError: Object message has no method 'replace'
TypeError: Object message has no method 'replace'
at Object.exports.parse (/usr/local/lib/node_modules/hexo/node_modules/swig/lib/parser.js:437:19)
at parse (/usr/local/lib/node_modules/hexo/node_modules/swig/lib/swig.js:343:19)
at Object.precompile (/usr/local/lib/node_modules/hexo/node_modules/swig/lib/swig.js:473:23)
at Object.compile (/usr/local/lib/node_modules/hexo/node_modules/swig/lib/swig.js:588:16)
at exports.commitMessage (/usr/local/lib/node_modules/hexo/lib/plugins/deployer/util.js:17:15)
at /usr/local/lib/node_modules/hexo/lib/plugins/deployer/github.js:114:26
at /usr/local/lib/node_modules/hexo/node_modules/async/lib/async.js:610:21
at /usr/local/lib/node_modules/hexo/node_modules/async/lib/async.js:249:17
at iterate (/usr/local/lib/node_modules/hexo/node_modules/async/lib/async.js:149:13)
at /usr/local/lib/node_modules/hexo/node_modules/async/lib/async.js:160:25
Terminal (having seen this on some of my previous attempts, I knew that a clean would fix this):
hexo clean
Result:
[info] Deleted cache file
[info] Deleted public directory
Terminal:
hexo deploy
Result:
[info] Files loaded in 0.063s
[create] Generated: archives/index.html (35ms)
[create] Generated: archives/2014/index.html (6ms)
[create] Generated: archives/2014/09/index.html (6ms)
[create] Generated: index.html (6ms)
[create] Generated: 2014/09/26/hello-world/index.html (13ms)
[create] Generated: js/script.js (1ms)
[create] Generated: css/style.css (349ms)
[create] Generated: css/fonts/FontAwesome.otf (0ms)
[create] Generated: css/fonts/fontawesome-webfont.eot (1ms)
[create] Generated: css/fonts/fontawesome-webfont.svg (0ms)
[create] Generated: css/fonts/fontawesome-webfont.ttf (1ms)
[create] Generated: css/fonts/fontawesome-webfont.woff (0ms)
[create] Generated: css/images/banner.jpg (1ms)
[create] Generated: fancybox/blank.gif (0ms)
[create] Generated: fancybox/fancybox_loading.gif (1ms)
[create] Generated: fancybox/fancybox_loading@2x.gif (0ms)
[create] Generated: fancybox/fancybox_overlay.png (0ms)
[create] Generated: fancybox/fancybox_sprite.png (1ms)
[create] Generated: fancybox/fancybox_sprite@2x.png (0ms)
[create] Generated: fancybox/jquery.fancybox.css (0ms)
[create] Generated: fancybox/jquery.fancybox.js (0ms)
[create] Generated: fancybox/jquery.fancybox.pack.js (0ms)
[create] Generated: fancybox/helpers/fancybox_buttons.png (1ms)
[create] Generated: fancybox/helpers/jquery.fancybox-buttons.css (0ms)
[create] Generated: fancybox/helpers/jquery.fancybox-buttons.js (0ms)
[create] Generated: fancybox/helpers/jquery.fancybox-media.js (1ms)
[create] Generated: fancybox/helpers/jquery.fancybox-thumbs.css (1ms)
[create] Generated: fancybox/helpers/jquery.fancybox-thumbs.js (0ms)
[info] 28 files generated in 0.428s
[info] Start deploying: github
[info] Clearing .deploy folder...
[info] Copying files from public folder..
Terminal:
git remote -v
Result (still in parent directory):
fatal: Not a git repository (or any parent up to mount point /Volumes/Macintosh HD)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Terminal:
cd .deploy
git remote -v
Result: no actual result just a new command line
Terminal:
cd .git
ls
Result:
COMMIT_EDITMSG HEAD config description hooks index info logs objects refs
Terminal (I don't know enough git to do anything else with the previous info. The only git troubleshooting command I know at this point is git status
):
git status
Result:
fatal: This operation must be run in a work tree
Terminal (I don't think I have two-factor authorization, but on the chance that I did, and that it might create a working tree, I followed your steps on pushing to Github pages):
git push github master
Result:
fatal: 'github' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
TypeError: Object message has no method 'replace'
on the very first run of hex deploy
is meaningful, but I don't know what to do with it. (On my previous attempts, I assumed I had mucked around enough with other things that maybe I had jacked up something. But this was as clean a process as I can do.).deploy/.git
directory's existence is good, but the lack of a working tree is the problem. git init
or git clone
. Without knowing whether I should or shouldn't, I had tried those on previous attempts.Maybe you can try to remove branch
and message
settings.
deploy:
type: github
repo: git@github.com:metasean/metasean.github.io.git
@tommy351
Here's the jist of what I did after I recovered, and the results:
_config.yml:
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: github
repo: git@github.com:metasean/metasean.github.io.git
Terminal:
hexo clean // green and good results
hexo generate // green and good results
hexo deploy
Username for 'https://github.com': metasean // I hadn't been prompted for these before,
Password for 'https://metasean@github.com': // so these strike me as a good sign
Result:
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/metasean/metasean.github.io.git'
[info] Deploy done: github
I also changed the _config to the following:
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: github
repo: https://github.com/metasean/metasean.github.io.git
branch: gh-pages # [branch]
message: "initial commit" #[message]
But got similar results (including prompts for username & password):
error: src refspec gh-pages does not match any.
error: failed to push some refs to 'https://github.com/metasean/metasean.github.io.git'
[info] Deploy done: github
This definitely seems like the right track, but I'm still missing something.
You can either send through some more information as described below in the diagnose the problem section, or you can use a suggested fix
Run the following commands in the metasean.github.io/.deploy
directory on your computer to help us understand what is going on
git show-ref
git log --oneline --decorate --graph
1 - Delete your metasean.github.io
repository on github. Recreate the metasean.github.io
repository and do not include a README or licence file when creating the repository.
2 - Delete the metasean.github.io/.deploy
directory on your computer
3 - Edit the metasean.github.io/_config.yml
file and set the deploy configuration exactly as follows
deploy:
type: github
repo: https://github.com/metasean/metasean.github.io.git
branch: master
Master is the branch you should be using for a user repo, that is a repo that has the form accountname.github.io. Github repositories with any other name use the gh-pages branch.
4 - Run the following hexo commands from the metasean.github.io
directory on your computer
hexo clean
hexo generate
hexo deploy
You should be prompted for your Github username and password
5 - Keep your fingers crossed. If it doesnt work then run the following commands from the metatsean.github.io/.deploy
directory and copy the results to this issue
git show-ref
git log --oneline --decorate --graph
You are prompted for a username and password because you are using a secure protocol https
and you need to identify yourself. Whilst you can read repositories on github anonymously, you must have a verifiable identity to push changes to a repository. If you use the https
protcol then you are prompted for a username & password.
If you use the
git@github.com
protocol then you can create an SSH key and add it to your github account. There are instructions to set up an SSH key on Github help. This saves you typing in your password each time but requires a key to be set up on any computer you use with github.
@jr0cket - We have lift-off! :rocket:
Thank you for the explanation on the difference between git@github.com
and https
protocols. I knew that I had set up SSL on my computer, but that I still occasionally was still asked for my password. I finally understand why! (I'm feeling all edumacated! :mortar_board: :sunglasses:) After validating it with the https
protocol, I changed my _config.yml
to the SSL version and it's equally happy.
hexo clean
and hexo generate
not automatically done at the beginning of the hexo deploy
? (Not complaining, just trying to understand.)Thank you's again to @jkuetemeier, @jr0cket, and @tommy351 for helping me get up and running!!! And a special thanks to @tommy351 for starting such an awesome node.js blogging framework and making it open source!!!
@tommy351
Removing the branch
setting in _config.yml
works for me! Thanks! :+1:
Why are hexo clean and hexo generate not automatically done at the beginning of the hexo deploy? (Not complaining, just trying to understand.)
cannot agree more!
Trying to setup the local page for our hacker space results into:
<%- partial('_partial/head') %>
<%- partial('_partial/header', null, {cache: !config.relative_link}) %>
<%- body %>
<% if (theme.sidebar && theme.sidebar !== 'bottom'){ %> <%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %> <% } %>
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
<%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %> <%- partial('_partial/after-footer') %>
_config.yml:
deploy:
type: github
repo: git@github.com-mms:munichmakes/munichmakes.github.io.git
branch: master
message: deploy
it works now, I guess the .nojekyll file was missing, and subsequently introduced errors while debugging. this post is helpful how to deploy http://stackoverflow.com/questions/27399219/repo-setup-for-hexo
I'm trying to set up a hexo blog for my github pages, but nothing I have done has worked. As a final test I did the following.
hexo init metasean.github.io
(everything looks good)cd metasean.github.io
npm install
(everything looks good)with
hexo deploy
The terminal message returned is:
I've been through the online docs and I'm not seeing any other deployment settings that must be changed in order to deploy to Github. Please help; what am I missing?