Adding an empty directory to a Git repository

Unlike with Subversion, one cannot add an empty directory to a Git repository. Naturally, there’s a way around this. Create a .gitignore file within the subdirectory and add these lines: # Ignore everything inside this subdirectory… * # …except for this file !.gitignore As the comments detail, the first line tells Git to ignore everything […]

Pushing a local repository to GitHub

One of Git’s strengths is the ability to configure a repository locally, so you can dive right into an idea regardless of whether or not you have a reliable (and secure) internet connection. Once you’re ready to share your code, one of the easiest and cheapest ways to do so is to import this local […]

Updating a fork to the master branch on GitHub

GitHub makes it very simple to fork — or create a personal copy of — a public repository. While I could easily star a repository I found interesting (or watch it), I tend to fork instead, thinking, somewhat optimistically, that I’m going to dig in and immediately start contributing. As the saying goes, “l’enfer est […]

Cloning a repository with submodules

A submodule is a repository dependency. This means that while it’s needed for a given repository, it isn’t part of that repository, having instead a separate repository of its very own. This subtle nuance can present itself in the form of a particularly opaque problem when cloning a project with submodules. Let’s say you’re cloning […]

Associating a username with a repository

When working with a private repository, GitHub will force you to provide a username and password (or personal access token if two-step authentication has been configured) every time you want to do anything that affects the repository (e.g. clone, pull, push, fetch). If you associate a specific username with the repository (from a user authorized […]

How to avoid a 403 Forbidden error when cloning a private repository

Sometimes when I’m trying to clone a private repository to a remote host, I get a 403 Forbidden error, like so: git clone Initialized empty Git repository in /home/public_html/.git/ error: The requested URL returned error: 403 Forbidden while accessing fatal: HTTP request failed No prompt for a username and password, just the door […]