Alternative option to upload a file to GitHub without cloning the entire repository
-
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