Skip to content

Commit

Permalink
Better wording around tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
nmagee committed Aug 13, 2024
1 parent a82ce2b commit 32ce2d6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/creating-repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,22 @@ Assuming you are authenticating to GitHub using SSH keys, here are the steps to
1. Within [GitHub](https://github.com/) find the existing repository you want to clone.
2. From the repository page, find the blue "Code" button, and select the SSH tab within the dropdown. If you are using a PAT for authentication, use the HTTPS address.
3. Copy the address, which will look something like `[email protected]:UVADS/git-basics.git` (SSH) or `https://github.com/UVADS/git-basics.git` (HTTPS).
4. In the command-line on your local computer, clone the repo:
4. In the command-line on your local computer, clone the repo. If using an SSH key to authenticate to GitHub, use this format:

```
git clone [email protected]:UVADS/git-basics.git
```
If using a PAT to authenticate to GitHub, be sure to insert your token in the clone command like this:
```
git clone https://[email protected]/UVADS/git-basics.git
5. This will create a new subdirectory with the name of the repository. You can change the name of the directory if you like.
6. If there are multiple branches in the GitHub repository and you want to clone them all, use these commands (using this repository as an example):
```
# Using SSH
git clone [email protected]:UVADS/git-basics.git
cd git-basics/
git fetch --all
Expand All @@ -57,6 +63,16 @@ Assuming you are authenticating to GitHub using SSH keys, here are the steps to
done
```
```
# Using a PAT
git clone https://[email protected]/UVADS/git-basics.git
cd git-basics/
git fetch --all
for branch in `git branch -r | grep -v HEAD`; do
git checkout -b $branch $branch
done
```
7. Note that if you create a new, empty repository within GitHub, it is helpful to tick the box to include a `README.md` file by default. This ensures that a default branch (named `main`) will be created for you.
Expand Down
16 changes: 16 additions & 0 deletions docs/git-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ destination [email protected]:mst3k/some-repo.git (fetch)
destination [email protected]:mst3k/some-repo.git (push)
```

## Change from SSH to Token Authentication

If you cloned an existing repository using SSH, you can easily update your local `git` to use tokens instead.

From within the repo, and assuming you already have a PAT created, issue this command (inserting your token in the URL):

```
git remote set-url origin https://[email protected]/UVADS/git-basics.git
```

Or if you have saved your PAT as a local `env` variable, use that instead:

```
git remote set-url origin https://[email protected]/UVADS/git-basics.git
```

## Bonus - So You Think You Know Git

In this video Scott Chacon, one of the co-founders and original developers of GitHub, talks about buried and advanced features in Git and GitHub.
Expand Down

0 comments on commit 32ce2d6

Please sign in to comment.