📓
Everything I Know
  • index
  • #
    • 3D Printing
  • A
    • Abandoned Spaces
    • ADHD
    • Aging
    • Algorithms & Data Structures
      • Array
      • Constraint Satisfaction Problem
      • Dynamic Programming
      • Graph
      • Hash Table
      • Heap
      • Linked List
      • Queue
      • Recursion
      • Set
      • Stack
      • Tree
      • Trie
      • Union Find
    • Amazon Web Services
    • Android
    • Anime, Comics & Manga
    • APIs
    • Artificial Intelligence
    • Assembly
      • ARM
      • MIPS
      • x86
    • Audio / Video Editing
    • Awesome
    • Azure
  • B
    • Board Games
    • Books
  • C
    • C (programming language)
    • C++
    • Cars
    • Cascading Style Sheets
    • Chess
    • Comedy
    • Command Line
      • Autotools
      • Awk
      • Bash scripting
      • Grep
      • Lsof
      • Sed
      • SSH
    • Competitive Programming
    • Compilers
    • Computer Graphics
      • OpenGL
      • Vulkan
      • WebGPU
    • Computer Networks
    • Computer Science
    • Concurrency
    • Continuous Integration / Delivery
    • Cooking
    • Cryptography
    • Cryptocurriencies
    • Curriculum Vitae
  • D
    • Databases
      • PostgreSQL
      • SQL
      • SQLite
    • Design Patterns
    • Digital Minimalism
    • Distributed Systems
    • Docker
    • Documentaries
    • Documentation
    • Domain Name System
    • Dopamine
    • Drawing
  • E
    • eCommerce
    • Electronics
      • Repairs
    • Engineering
    • Entrepreneurship
    • Events
  • F
    • Fashion
    • Fitness
      • Exercise
      • Nutrition
      • Weight Loss
    • Focus
    • Football
  • G
    • Game Development
      • Godot
      • LibGDX
      • Unity
      • Unreal Engine
    • Git
    • Goals
    • Guitar
  • H
    • Habits
    • Happiness
    • House
      • Tradespeople
      • Buying
      • Renting
  • I
    • Interviews
      • Behavioural Interviews
      • Coding Interviews
      • System Design Interviews
  • J
    • Java
    • JavaScript
      • Astro
      • Bun
      • Electron
      • Jest
      • Node.js
      • Nue.js
      • React.js
      • Redux
      • Vue.js
    • Journaling
  • K
    • Karting
    • Knots
    • Knowledge Bases
    • Kotlin
    • Kubernetes
  • L
    • LaTeX
    • Learning
      • Drawing
      • Languages
        • Certificate of Proficiency in English
        • Japanese
      • Piano
    • Legacy Code
    • LEGO
    • Lifestyle
    • Life Hacks
    • Linux
    • LISP
  • M
    • Machine Learning
      • Deep Learning
    • MacOS
    • Maths
    • Meditation
    • Movies
    • Music
      • Music Production
      • Music Theory
  • N
    • Negotiation
    • News
  • O
    • Operating Systems
      • Linux
  • P
    • Parenting
    • Personal Finance
      • ISAs
      • Pensions
    • PHP
    • Physics
    • Podcasts
    • Procrastination
    • Productivity
    • Programming
      • Functional Programming
      • Performance
    • Prometheus
    • Psychology
    • Public Speaking
    • Purpose
    • Puzzles
    • Python
      • Django
      • Pandas
  • Q
    • Quantum Computing
    • Quotes
  • R
    • Regular Expressions
    • Relationships
    • Reverse Engineering
    • Rust
      • Cargo
  • S
    • Security
      • Android
      • Binary Exploitation
      • CompTIA Security+ SYO-701
      • CTFs
      • Forensics
      • Linux
      • Web
      • Windows
    • Self Improvement
    • Shaving
    • Sitting
    • Sleep
    • Social Skills
    • Spring (framework)
    • Stoicism
    • Strength Training
      • Deadlifts
      • Push Ups
    • Success
    • System Design
      • Site Reliability Engineering
  • T
    • Table Tennis
    • Testing
    • Thinking
    • Touch Typing
    • Travel
      • Japan
        • Fukuoka
        • Hiroshima
        • Kyoto
        • Okinawa
        • Osaka
        • Tokyo
      • London
      • Rome
    • TV Series & Programmes
    • Twitch
    • TypeScript
    • Typography
  • V
    • Virtual Tours
    • Vim
    • Video Games
      • Emulation
      • Mods
      • Music
      • Speedrunning
      • Warzone
  • W
    • Web Apps
    • Web Cams
    • Web Development
      • Selenium
      • Web Assembly
    • Windows
      • Windows Development
    • Work
      • Freelancing
      • GitHub Profile
      • Interesting Companies
      • Job Boards
      • Remote Work
      • Startup
    • Writing
Powered by GitBook
On this page
  • Notes
  • Useful commands
  • Add a new remote repository
  • Create a fixup commit
  • Rename current branch
  • Resources
  • Alternatives
  • Articles
  • Books
  • Images
  • Tools
  • Videos
  • Websites

Was this helpful?

  1. G

Git

https://git-scm.com/

Notes

  • When you run the git init command, Git creates a .git directory in the directory from where the command was launched. Everything Git needs to work is in there.

  • When you run the git add command, Git writes files to the staging area of the repository. When you run git commit, Git creates a commit object (with an ID), and it applies references (= labels) to that commit (HEAD and the branch you are on).

  • When you run the git branch command, Git just created a new reference with the name of the newly created branch, and applies it to the HEAD commit.

  • When you run the git checkout command, Git switches the branch it's going to advance when you commit.

  • An ID in Git is a checksum of the content of the commit, the author, the date, the log message, and the previous commit ID. Every ID is unique, so every commit is unique (as changing even slightly just one of the variables above will generate a completely different checksum).

  • When you run the git merge <branch> command, two situations are possible:

    • Git recognises the current branch is an ancestor of the branch to be merged: in this case, Git will perform the merge by fast-forwarding, i.e. it will just update references;

    • Git recognises the current branch is not an ancestor of the branch to be merged: in this case, Git will create a new commit (with two parents), and will move the master and the HEAD references (but not the branch one).

  • Thanks to the fact that every ID is unique, every commit is unique, commits do not change, and IDs depend on previous commits, Git is able to retrieve the full history of a commit just given its ID. This is very useful when you run the git push command, as it will send to origin only the minimum set of commits to make the two repositories the same.

  • When you run git tag, Git will create a new reference and attach it to a commit. The main difference of a tag is that it never moves after being created.

  • The reflog is a summary of the latest commits Git has interacted with. It can be useful in rescue situations when some of the commits have been done from a detached HEAD situation, meaning there was no branch associated with them.

Useful commands

Add a new remote repository

git remote add <remote_name> <remote_url>

Create a fixup commit

git commit --fixup <hash>

Rename current branch

git branch -m <new_name>

Resources

Alternatives

Articles

  • Git's database internals - Derrick Stolee

Books

Images

Tools

Videos

Websites

PreviousUnreal EngineNextGoals

Last updated 4 months ago

Was this helpful?

- Meta

- Tobias Günther

- Michael Gattozzi

- Derrick Stolee

- Julia Evans

- Dmitry Mazin

- Roger Dudler

- Julia Evans

- Scott Chacon

- Julia Evans

- Julia Evans

- Julia Evans

- Martin Heinz

- Matt Neuburg

- Julia Evans

- Julia Evans

- Abin Simon

- Lup Peng

- John Wiegley

- Scott Chacon, Ben Straub

- Michael Schwern

- Scott Chacon

- Scott Chacon

Fossil
Pijul
Sapling
A look under the hood: how branches work in Git
Better Git Conflicts with zdiff3
Commits are snapshots, not diffs
Confusing git terminology
Demystifying git submodules
git - the simple guide - no deep shit!
git branches: intuition & reality
Part I: packed object store
Part II: commit history queries
Part III: file history queries
Part IV: distributed synchronization
Part V: scalability
Git Tips and Tricks
Git Tips 1: Oldies but Goodies
Git Tips 2: New Stuff in Git
Git Tips 3: Really Large Repositories
How HEAD works in git
In a git repository, where do your files live?
Inside .git
Modern Git Commands and Features You Should Be Using
Most common git screwups/questions and solutions
Picturing Git: Conceptions and Misconceptions
Popular git config options
The "current branch" in git
What is in that .git directory?
When to Use Each of the Git Diff Algorithms
Git from the Bottom Up
Pro Git
lazygit
15 Lazygit Features In Under 15 Minutes
Git For Ages 4 And Up
So You Think You Know Git
So You Think You Know Git Part 2
Git Exercises
Git Explorer
Learn Git Branching
Oh My Git!