Git

Git is a Version Control System (VCS) that tracks changes in files contained within a repository.

What is the Difference Between Git and GitHub?

GitHub is a cloud-based hosting service that lets you manage Git repositories. This makes it easy to share local repositories with others in both a public and private manner.

Git is a version control system that uses repositories to track changes and includes a history of said changes. It is installed locally on your computer. You can download it herearrow-up-right. It is recommended to install VS Code first, and make that your default git editor when going throught the git installation.

Getting started

Signing in locally

In order to commit changes to your repository, you must have a username and an email setup. to set these, run git config --global user.name <username> and git config --global email <email>

Creating a repository

You can create a repository in two ways, from scratch or from an already made repository.

To create a repository from scratch, navigate to the directory you want to track and type git init into the console.

To copy an already existing repository, run git clone <url>, where <url> is the location of the remote git repository.

circle-info

On GitHub, you can obtain the link to a repository by clicking on code, HTTPS, and hitting copy.

circle-info

Make sure that the remote URL ends with .git

Commands

add

git -A

git -a <file.extension>

Add files to be tracked.

status

commit

git commit -m "message"

Stages tracked files.

pull

git pull

Pulls down remote changes and updates your local repository. If you have changes, you might have to stash them or delete them

push

git push

This pushes local changes to the remote repo. If there are conflicts, which can happen when two people work on the same file, you will need to rebase or merge the differences into a single commit, which will then be the head

fetch

git fetch

Fetches changes from remote without overriding your local changes

merge

rebase

reset

branch

circle-info

Refer to this cheat sheetarrow-up-right if you need a quick refresher

Last updated

Was this helpful?