Problems with the GitHub Default Remote Using SSH

Posted on Wed 28 May 2025 in git, GitHub • Tagged with git, GitHub

Second time that I have this problem, so I thought I would write it down.

When I create a new repository on GitHub, the default instructions to add the remote repository to my local git repository are:

git remote add origin git@github.com:my_username/new_repo_name.git
git branch -M main
git push -u origin main

The problem is that this assumes that I'm using the SSH protocol to connect to GitHub. However, I prefer using HTTPS for my connections. Therefore, I need to change the remote URL to use HTTPS instead of SSH. To do this, I can use the following command:

git remote set-url origin https://github.com/my_username/new_repo_name.git

To avoid this, the instructions to add the HTTPS connection directly should be:

git remote add origin https://github.com/my_username/new_repo_name.git
git branch -M main
git push -u origin main

Essential git cheat sheet for loners

Posted on Wed 22 January 2025 in git • Tagged with git

This are the basic commands to operate with git as a loner: no branches, no remotes, no merges... Just the basic stuff.

The minimum concepts you need to know are:

  • Git is a version control system. It allows you to store changes in your files. Don't mix it with GitHub, which is a platform to store your repositories.
  • Working directory: the directory where you are working.
  • Staging area: a place to store changes before committing them.
  • Repository: the place where the changes are stored.
  • Commit: a set of changes stored in the repository. They are identified by a hash. For example, commit 1234567.

The basic workflow is:

  1. Make changes in the working directory.
  2. Add changes to the staging area.
  3. Commit changes to the repository.
  4. Repeat.

Conceptually: working directory -> staging area -> repository.

Configuration

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"

Create a new repository

In the directory of your project:

git init

Add files to the repository

This adds all the changes in your current directory to the …


Continue reading