-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
|