Git Cheat Sheet

#Git

Removing a file from the Git repository that was added to .gitignore

git rm -r --cached file_name

Without --cached the file will be removed from both the Git repository (.git folder) and the file system

Creating an empty commit

git commit --allow-empty -m "empty commit"

The -m flag indicates to use the specified commit message (which can be taken from a file or the commit).

This article will be periodically updated

Viewing remote repositories

git remote -v

This command shows the list of remote repositories associated with the local repository, along with their fetch and push URLs.

Adding a remote repository

git remote add <remote_name> <remote_url>

git remote add github git@github.com:username/repo.git

This command adds a new remote repository with the specified name and URL.

Viewing detailed remote repository information

git remote show origin

This command displays detailed information about the origin remote repository, including fetch and push URLs, remote branches, local branches configured for push/pull operations and the status of tracking branches.

Updating remote repository references

git remote update

This command fetches updates from all remote repositories without merging them into your local branches. It updates the remote-tracking branches to reflect the current state of the remote repositories.