How to use github via HTTPS?
Solution 1
Do it via SSH (but first upload your public key to github):
set the remote URL to:
git@github...
Solution 2
You may check the correct https url by looking at the right bottom panel of your project front page. There'll be a a section called HTTPS clone URL that you can get the link you want. For me, it generates something like https://github.com/COMPANYORUSER/REPONAME.git
.
You can click on the SSH link to make the URL change to a SSH clone link.
But I noticed your script is creating a blank repo on your local machine, committing and then adding the the remote to the repository. You could simplify it by cloning the entire remote directly using the clone link github provides. This way your script will be a little simpler
git clone HTTPS_CLONE_LINK_FROM_GITHUB
cd REPONAME
echo thisisatest > index.html
git add .
git commit -m "upgrade"
git push origin master
You still need to setup your email address and name as you did in the first lines, but you only need to do this once per machine, unless you want for some reason have different users per repository. In this case you'll have to configure each of them, but omitting the --global
, thus making them local to your current repo.
LoukiosValentine79
Updated on September 18, 2022Comments
-
LoukiosValentine79 over 1 year
I'm trying with this to create a simple static HTML website using github. I already created a repository named: "GITHUBUSERNAMEANDREPO".
#!/bin/bash git config --global user.name "GITHUBUSERNAMEANDREPO" git config --global user.email "[email protected]" mkdir GITHUBUSERNAMEANDREPO cd GITHUBUSERNAMEANDREPO echo thisisatest > index.html git init git add . git commit -m "upgrade" git remote add mainsite "https://[email protected]/GITHUBUSERNAMEANDREPO.github.io.git" git remote -v git push mainsite master
When I run this script I get a popup under RHEL 6.6 Desktop for my OpenSSH private key's password.
Question: Can I use github via HTTPS without using any ssh? What am I missing, maybe I'm using a bad remote?
-
LoukiosValentine79 about 9 years"fatal: Not a git repository (or any of the parent directories): .git" - after a "git push origin master"
-
Henrique Jung about 9 yearsAre you sure your
git clone
was sucessful? Try to type these commands by hand and capture individual errors. Somehow git is not finding the cloned repo.