Skip to content

Instantly share code, notes, and snippets.

@tecmaverick
Last active March 27, 2026 03:33
Show Gist options
  • Select an option

  • Save tecmaverick/e81330a61ae89aedd3b8e6b2bfeb605b to your computer and use it in GitHub Desktop.

Select an option

Save tecmaverick/e81330a61ae89aedd3b8e6b2bfeb605b to your computer and use it in GitHub Desktop.
Github Commands
GIT ARCH
1. Git takes a snapshot of the entire file when its changed, instead of delta changes. Every time you commit, or save the state of your project, Git basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored. Git thinks about its data more like a stream of snapshots.
2. In Git is checksummed before it is stored and is then referred to by that checksum. Using SHA-1 hash. Git stores everything in its database not by file name but by the hash value of its contents.
3. When you do actions in Git, nearly all of them only add data to the Git database. The Three States of file changes
3.1 Modified - Changed the file but have not committed it to your database yet.
3.2 Staged - have marked a modified file in its current version to go into your next commit snapshot.
3.3 Committed - Data is safely stored in your local database.
========================================================================================================================
GIT CONFIG
# Fetch git config. Current or Global settings
git config --list
# Show the config where its came from
# 1. [path]/etc/gitconfig file: Contains values applied to every user on the system and all their repositories. Requires Admin privileges
# 2. ~/.gitconfig or ~/.config/git/config file: Values specific personally to you, the user. Read and write to this file specifically by passing the --global option, and this affects all of the repositories you work with on your system.
# 3. config file in the Git directory (that is, .git/config) of whatever repository you’re currently usin
git config --list --show-origin
# Configuring Git after install for current user. This will be used by all repos unless specifically overriden
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
# Set default branch name
git config --global init.defaultBranch main
# Read specific Git config
git config user.name
========================================================================================================================
GIT REPO
# Initialise an existing repo as git repo
git init
#add all files of specific extension to GIT repo
git add *.c
git add LICENSE
git commit -m 'Initial project version'
# Get an existing GIT repo
git clone https://git.kernel.org/pub/scm/git/git.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment