Skip to content

Instantly share code, notes, and snippets.

@liang799
Created October 19, 2023 13:51
Show Gist options
  • Save liang799/76dbcfe8cd80566974df9a7db5c0b4aa to your computer and use it in GitHub Desktop.
Save liang799/76dbcfe8cd80566974df9a7db5c0b4aa to your computer and use it in GitHub Desktop.
Git notes

My notes for Git

Taken from Git Pro and StackOverflow

Commands

git add

Stages a file

git commit

Creates a checksum for staged files

git status -s

Short status flag to see changes in a more compact way

git fetch

Downloads commits, objects and refs from another repository. It fetches branches and tags from one or more repositories.

git pull

git fetch + git merge

Good to know

GitHub

Software as a Service. Hosts your remote repository.

Snapshots

Git takes snapshots of changes instead of noting changes over time.

Everything in Git is checksumed

Meaning it is impossible to change the contents of any file/directory without Git knowing

The 3 main states

modified, staged, commited

Types of tags

lightweight and annotated

Tags

Most people use this functionality to mark release points i.e. v1.0.0

Lightweight Tags

Branch that doesn't change: pointer to a specific commit (best practise: temporary tags)

Annotated Tags

Stored as full objects in the Git database

Branches

Diverge from the main line of development and continue to do work without messing with that main line.

Workflows

Long running and topic branches.

Pointers

Branches are pointers that point to a commit. They are cheap to create and destroy.

How Git knows the user current branch position

There is a special pointer called HEAD

Unable to switch branch

Because of uncommited changes that conflict with the branch you're checking out.

Switching branches

Git resets your working directory to mimic your last commit on the current branch.

Conflicting changes

Pauses the merging proces to let the user resolve the conflict

Jargon

Staged

Mark a modified file in its current version to go inot your next commit snapshot

Staging area

AKA index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment