- create key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
or get public key of .ssh key you have locally
pbcopy < ~/.ssh/id_rsa.pub
- add .pub key to github settings area for your account - https://github.com/settings/keys
- test key
ssh -T git@github.com
- set the remote origin
git remote set-url origin git@github.com:{username}/{reponame}.git
- test that you can edit/add/commit/push
git add . git commit -a -m "Update README.md" git push
- If you're using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
- First, check to see if your ~/.ssh/config file exists in the default location.
$ open ~/.ssh/config
If the file doesn't exist, create the file.touch ~/.ssh/config
- Open your ~/.ssh/config file, then modify the file to contain the following lines. If your SSH key file has a different name or path than the example code, modify the filename or path to match your current setup.
Notes:Host github.com AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519
If you chose not to add a passphrase to your key, you should omit the UseKeychain line.
If you see a Bad configuration option: usekeychain error, add an additional line to the configuration's' Host *.github.com section.
Host github.com IgnoreUnknown UseKeychain
Version for key without passcode
Host github.com AddKeysToAgent yes IdentityFile ~/.ssh/id_rsa IgnoreUnknown UseKeychain
- Add your SSH private key to the ssh-agent and store your passphrase in the keychain. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
ssh-add --apple-use-keychain ~/.ssh/id_rsa
- First, check to see if your ~/.ssh/config file exists in the default location.
Pushing / Pulling / Cloning
You have to use the ssh method:git@github.com:{username}/{reponame}.git
git push --set-upstream origin 7ShawneeeMini:7ShawneeeMini
Table of contents
This short GitHub Pages tutorial discusses:
- Intended audience
- Create a GitHub Account
- Create a GitHub repository
- Edit the main GitHub Pages README file in /docs/README.md
- Enable GitHub Pages so you can create and publish a formatted website
- Create a web page on GitHub using Markdown
- GitHub Pages directory and file usage
- Create Markdown links to other pages on your own site
- Headers in Markdown
- Create Markdown links to other sites
- Create Markdown links to the interior of a page
- Add an assets directory to your GitHub Pages site
- Change the appearance of your GitHub Pages site using Jekyll themes
- Add images to your GitHub Pages site
- Determine your GitHub Pages URL
- Privacy warning
- Add a GitHub Pages preview link to your README.md
Privacy warning: GitHub Pages sites are public even if your repo is private
GitHub allows you to create private repos. All GitHub Pages sites are generated from GitHub repos. However, GitHub Pages allows you to create a publication from a private repo. Currently there’s no way to turn off this feature, so don’t use a GitHub Pages link unless you want your private repo to be visible to the entire Internet.
https://tomcam.github.io/least-github-pages/github-pages-url.html
Determining your GitHub Pages URL
It can be a little confusing, but when you’re using GitHub and viewing a Markdown page you’re seeing a simple HTML rendering of that page with a fixed style sheet chosen by GitHub. You need a different link to view it in GitHub Pages using one of the GitHub Pages Jekyll themes.
All you have to do to see your document with its final formatting is figure out the GitHub Pages address. Here’s the Markdown source to both links:
View on [Github Pages](https://tomcam.github.io/least-github-pages/)
View on [Github](https://github.com/tomcam/least-github-pages/)
Here’s how to create the GitHub Pages URL from the GitHub URL.
Get the full URL of your GitHub repo
Your first job is to make sure you know the full URL of your GitHub repo. For example, the name of this
repository is https://github.com/tomcam/least-github-pages
. Here’s how it breaks down.
Start with the GitHub URL
Recalling Creating a GitHub repository for your projects, your GitHub repository address is always made up of these components:
The GitHub website URL:
https://github.com/
Add the username and a slash
Followed by your GitHub username/account name, and a /
slash. The creator of this repo has the
GitHub username tomcam
, for example.
https://github.com/tomcam/
Add the name of your GitHub repo
Followed by the name of the repo, so:
https://github.com/tomcam/least-github-pages
The GitHub Pages repository URL is always https://{userid}.github.io/{reponame}
The GitHub Pages URL is based on the GitHub repo URL, and takes the format
https://{userid}.github.io/{reponame}
. The moment you use it, GitHub Pages will generate a website
based on the contents of your repo.
Use the elements of your GitHub repo URL to derive your GitHub Pages URL
Taking the parts of your URL, create the GitHub pages URL for it this way:
Start with https:// and your username
- Start with
https://
followed your GitHub account name, and a period after that. For example, if your GitHub account name happened to betomcam
:
https://tomcam.
Add github.io
- Follow it with
github.io
, notgithub.com
:
https://tomcam.github.io
Add slash and the repo name
- Follow it with a slash
/
and your repo name. For example, if your repo name wereleast-github-pages
, the GitHub.io address would be:
https://tomcam.github.io/least-github-pages
Example
So this GitHub URL:
[Github](https://github.com/tomcam/least-github-pages/)
Becomes:
[Github Pages](https://tomcam.github.io/least-github-pages/)
Note that the parts in square brackets, [GitHub]
in the first example, and
[GitHub Pages]
, can be any text. They form the clickable link in the final rendered HTML.
Add GitHub Pages preview link to your README.md
It helps to have a link like this near the top of the document so your audience can view either the themed GitHub Pages version or the GitHub repo preview:
View in [Github Pages](https://tomcam.github.io/least-github-pages/) or directly on [Github](https://github.com/tomcam/least-github-pages/)
* [Your GitHub Pages URL and adding preview to your README.md](/least-github-pages/add-github-pages-preview.html)
It can take a few moments to generate the current GitHub Pages site
GitHub Pages doesn’t generate your new website every time you make changes to a repo. It updates “lazily”, meaning that it won’t render the full Jekyll version of the site until someone actually browses to the GitHub Pages URL. It can take up several minutes for your GitHub Pages site to be generated after you add pages or made changes to existing ones.
https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories
GitHub's collaborative approach to development depends on publishing commits from your local repository to GitHub for other people to view, fetch, and update.
About remote repositories
A remote URL is Git's fancy way of saying "the place where your code is stored." That URL could be your repository on GitHub, or another user's fork, or even on a completely different server.
You can only push to two types of URL addresses:
- An HTTPS URL like
https://github.com/user/repo.git
- An SSH URL, like
git@github.com:user/repo.git
Git associates a remote URL with a name, and your default remote is usually called origin
.
Creating remote repositories
You can use the git remote add
command to match a remote URL with a name. For example, you'd type
the following in the command line:
git remote add origin <REMOTE_URL>
This associates the name origin
with the REMOTE_URL
.
You can use the command git remote set-url
to change a
remote's URL.
Choosing a URL for your remote repository
There are several ways to clone repositories available on GitHub.com.
When you view a repository while signed in to your account, the URLs you can use to clone the project onto your computer are available below the repository details.
For information on setting or changing your remote URL, see "Managing remote repositories."
Cloning with HTTPS URLs
The https://
clone URLs are available on all repositories, regardless of visibility.
https://
clone URLs work even if you are behind a firewall or proxy.
When you git clone
, git fetch
, git pull
, or git push
to a remote
repository using HTTPS URLs on the command line, Git will ask for your GitHub username and password. When Git
prompts you for your password, enter your personal access token. Alternatively, you can use a credential helper like
Git Credential
Manager. Password-based authentication for Git has been removed in favor of more secure authentication
methods. For more information, see "Managing
your personal access tokens."
If you are accessing an organization that uses SAML SSO and you are using a personal access token (classic), you must also authorize your personal access token to access the organization before you authenticate. For more information, see "About authentication with SAML single sign-on" and "Authorizing a personal access token for use with SAML single sign-on."
Tips:
- You can use a credential helper so Git will remember your GitHub credentials every time it talks to GitHub. For more information, see "Caching your GitHub credentials in Git."
- To clone a repository without authenticating to GitHub on the command line, you can use GitHub Desktop to clone instead. For more information, see "Cloning a repository from GitHub to GitHub Desktop."
If you'd rather use SSH but cannot connect over port 22, you might be able to use SSH over the HTTPS port. For more information, see "Using SSH over the HTTPS port."
Cloning with SSH URLs
SSH URLs provide access to a Git repository via SSH, a secure protocol. To use these URLs, you must generate an SSH keypair on your computer and add the public key to your account on GitHub.com. For more information, see "Connecting to GitHub with SSH."
When you git clone
, git fetch
, git pull
, or git push
to a remote
repository using SSH URLs, you'll be prompted for a password and must provide your SSH key passphrase. For more
information, see "Working
with SSH key passphrases."
If you are accessing an organization that uses SAML single sign-on (SSO), you must authorize your SSH key to access the organization before you authenticate. For more information, see "About authentication with SAML single sign-on" and "Authorizing an SSH key for use with SAML single sign-on" in the GitHub Enterprise Cloud documentation.
Tip: You can use an SSH URL to clone a repository to your computer, or as a secure way of deploying your code to production servers. You can also use SSH agent forwarding with your deploy script to avoid managing keys on the server. For more information, see "Using SSH agent forwarding."
Cloning with GitHub CLI
You can also install GitHub CLI to use GitHub workflows in your terminal. For more information, see "About GitHub CLI."
Cloning with Subversion
Note: Subversion support will be removed from GitHub on January 8, 2024. A future release of GitHub Enterprise Server after January 8, 2024 will also remove Subversion support. To read more about this, see the GitHub blog.
You can also use a Subversion client to access any repository on GitHub. Subversion offers a different feature set than Git. For more information, see "What are the differences between Subversion and Git?"
You can also access repositories on GitHub from Subversion clients. For more information, see "Support for Subversion clients."