PK º¼Aù˜õ8[ 8[ ! illustrated-git-latest/index.html
Each object has a type, a size and a content
Object type can be blob, tree, commit or tag
Used to snapshot a tree state
Has tree, parent(s), author, commiter and comment attributes
Reference an object
Has object, type, tagger and comment attributes.
Set your name and email:
$ git config --global core.name "Me"
$ git config --global core.email "me@company.com"
Display your config:
$ git config --global
$ git config --local # in a repository
Stage your changes:
# Add to index / stage
$ git add file.txt
# Add all modified and new files (tracked or not) to index
$ git add -A
# Partial staging
$ git add -p file.txt
Create a commit into the current branch:
# Commit from index
$ git commit
# Commit from tracked file list
$ git commit file1.txt file2.txt
# All modified tracked files
$ git commit -a
# Commit from pattern
$ git commit **/*.py
See the current status:
$ git status
Retrieve your history:
# Log intégral
$ git log
# 5 dernier commits
$ git log -5
# Diff between two branches
$ git log origin/master..master
Discard your changes for later:
# Create a stash
$ git stash
# list stashes
$ git stash list
# Apply a stash
$ git stash apply
# Apply a stash and drop it
$ git stash pop
# Clear your stashes
$ git stash clear
Revert back changes:
# Reverse commit
$ git revert {SHA1}
# Amend commit
$ git commit --amend
# Uncommit
$ git reset --mixed HEAD file
# Discard changes
$ git checkout file
# Reset branch to a given state
$ git reset --hard ref
$ git branch feature # Create the branch
$ git checkout feature # Switch to the new branch
# or in a single command
$ git checkout -b feature
Re-apply your commits and keeps your history linear:
$ git rebase master
# or interactive version
$ git rebase -i master
Pick a commit an apply it in the current branch as a new commit:
$ git cherry-pick {SHA1}
It’s only branches
Repository synchronization operations:
$ git fetch
$ git push
$ git pull # fetch + merge
$ git pull --rebase # fetch + rebase
TODO
Tune your ~/.gitconfig for comfort !
[alias]
st = status
ci = commit
co = checkout
br = branch
amend = commit --amend
rlog = log --pretty=oneline --abbrev-commit --graph --decorate
plog = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
unadd = reset --mixed HEAD
uncommit = reset --soft HEAD^
[color]
branch = auto
diff = auto
interactive = auto
status = auto
Please activate JavaScript to enable the search functionality.
From here you can search these documents. Enter your search words into the box below and click "search". Note that the search function will automatically search for all of the words. Pages containing fewer words won't appear in the result list.