If you haven't installed Git on your PC, download and install it from the official Git website.
Set your global username and email:
$ git config --list --show-origin
$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"
Use the following command to clone the repository to your PC:
$ git clone <repository-url>
Example:
$ git clone [email protected]:username/repository-name.git
- Replace
<repository-url>
with the SSH URL of your GitHub repository.
Change to the project directory:
$ cd repository-name
If you don’t have an SSH key, generate one:
$ ssh-keygen -t ed25519 -C "[email protected]"
- When prompted to save the key, press Enter to save it in the default location.
- If prompted, you may set a passphrase for additional security (optional).
Start the ssh-agent and add your SSH key:
```bash
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_ed25519
```
Display your public key:
$ cat ~/.ssh/id_ed25519.pub
- Copy the output of the key.
1). Go to GitHub SSH settings. 2). Click New SSH key. 3). Paste your public key into the provided field, give it a descriptive name, and click Add SSH key.
If your repository was cloned using HTTPS, change it to SSH:
$ git remote set-url origin [email protected]:username/repository-name.git
Edit or create files in your project directory as needed.
$ git add .
$ git commit -m "Your commit message"
$ git push origin main
- Replace
main
with the correct branch name if your default branch is different.
Use the following command to check the status of your repository:
$ git status