example of common git commands
This document based repo is a collection of git commands commonly used in daily work.
Github page url: https://binlecode.github.io/example-git-commands/
Table of contents
Simple git stash between branches
Simple git merge and cherry pick
Simple git sync forked repo to upstream
Simple git delete file recovery
Simple git slides example using MARP
Basic git workspace in a nutshell
In the figure above, Directory
means the project repository folder, under it:
.git/index
stores staged, but not commited, changes
.git/HEAD
stores local head commit
Git states
Git has three internal state management mechanism’s, The commit tree HEAD, The staging index, and the working directory.
The HEAD
HEAD is the pointer to the current branch reference, which is in turn a pointer to the last commit made on that branch. That means HEAD will be the parent of the next commit that is created. It’s generally simplest to think of HEAD as the snapshot of your last commit on that branch.
The Index
The Index is your proposed next commit. This is commonly viewed as Git’s “Staging Area” as this is what’s included in next commit.