-
Initialize an empty Git repository:
git init my-repository cd my-repository
-
Add a remote for the GitHub repository:
git remote add origin https://github.com/marioseixas/marioseixas.github.io.git
-
Configure sparse-checkout:
git config core.sparseCheckout true
-
Specify the directory you want to checkout (if applicable):
echo '_posts/*' >> .git/info/sparse-checkout
-
Fetch the main branch (change ‘main’ to your target branch if it’s named differently):
git fetch origin main
-
Checkout the files:
git checkout main
Git could ask for your GitHub credentials:
To set up your credentials with SSH for Git on your local machine after generating an SSH key and adding it to your GitHub account, follow these steps:
-
Ensure SSH Agent is Running:
You need to make sure the SSH agent is running so that it can manage your keys. You seem to have already started the ssh-agent and added your key. If needed again, you can use:
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519
-
Test Your SSH Connection:
Before you try to push your changes to GitHub, you should test your SSH connection. You can do this with the following command:
ssh -T git@github.com
You should see a message like “Hi username! You’ve successfully authenticated…”.
-
Configure Git to Use SSH:
If you haven’t already set Git to use SSH for GitHub, you can do so by changing your remote URL from HTTPS to SSH. Since you just added a deploy key for a specific repository, it’s tied to that repository only. The general command to change the remote URL is:
git remote set-url origin git@github.com:username/repository.git
Replace
username
with your GitHub username andrepository.git
with your repository’s name. -
Pushing Changes to GitHub:
When you push changes, Git will use your SSH key for authentication. Because you’ve added the key to the SSH agent, you should not be prompted for your passphrase again during the current session.
git push origin main
Important Note: Since you used a deploy key you showed in the example, and if you have set it up in the GitHub repository correctly, you can push to the repository as the key has read/write access. You must ensure that your Git remote URL uses the SSH format.
Reference: Initialize an empty Git repository: git init my-repository cd my-repository Add a remote for the GitHub repository: git remote add origin https://github.com/marioseixas/marioseixas.github.io.git Configure sparse-checkout: git config core.sparseCheckout true Specify the directory you want to checkout (if applicable): echo '_posts/*' >> .git/info/sparse-checkout Fetch the main branch (change ‘main’ to your target branch if it’s named differently): git fetch origin main Checkout the files: git checkout main Git could ask for your GitHub credentials: Generating SSH key Managing DEPLOY keys To set up your credentials with SSH for Git on your local machine after generating an SSH key and adding it to your GitHub account, follow these steps: Ensure SSH Agent is Running: You need to make sure the SSH agent is running so that it can manage your keys. You seem to have already started the ssh-agent and added your key. If needed again, you can use: eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519 Test Your SSH Connection: Before you try to push your changes to GitHub, you should test your SSH connection. You can do this with the following command: ssh -T git@github.com You should see a message like “Hi username! You’ve successfully authenticated…”. Configure Git to Use SSH: If you haven’t already set Git to use SSH for GitHub, you can do so by changing your remote URL from HTTPS to SSH. Since you just added a deploy key for a specific repository, it’s tied to that repository only. The general command to change the remote URL is: git remote set-url origin git@github.com:username/repository.git Replace username with your GitHub username and repository.git with your repository’s name. Pushing Changes to GitHub: When you push changes, Git will use your SSH key for authentication. Because you’ve added the key to the SSH agent, you should not be prompted for your passphrase again during the current session. git push origin main Important Note: Since you used a deploy key you showed in the example, and if you have set it up in the GitHub repository correctly, you can push to the repository as the key has read/write access. You must ensure that your Git remote URL uses the SSH format.