GIT
Coucou, tu veux voir mon git ?
Ingrid, est-ce que tu rebase ?
“I’m an egotistical bastard, and I name all my projects after myself. First Linux, now git.” – Linus
THE SHA-1
257cc5642cb1a054f08cc83f2d943e56fd3ebe99
THE SHA-1
257cc5642cb1a054f08cc83f2d943e56fd3ebe99
THE SHA-1
257cc5642cb1a054f08cc83f2d943e56fd3ebe99
THE SHA-1
--- .git
| |--- objects
| | |--- 25
| | | |--- 7cc5642cb1a054f08cc83f2d943e56fd3ebe99
The contents of your files
Your directories
The 'history' part of 'tree history storage system'
Permanent shorthand name for a particular commit
It's creating a file that has the SHA-1 of the last commit
It's moving the HEAD pointer of a branch to the latest SHA-1 commit of another branch
If there is changes on both sides, a commit with multiple parent will be created
Full sha-1
dae86e1950b1277e545cee180551750029cfe735
Partial sha-1
dae86e1
Branch or Tag name
master
Date spec
master@{yesterday}
master@{1 month ago}
Based on .git/logs files
Ordinal spec
master@{5}
Carrot parent
e65s46^2
master^5
Based on .git/logs files
Based on .git/logs files
Tilde spec
e65s46~5
equals to e65s46^^^^^
Carrot parent
e65s46^2
master^5
Tilde spec
e65s46~5
$ git config --global user.name "Nom et Prénom"
$ git config --global user.email mail@domaine.tld
$ git config --global core.autocrlf input
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = git@github.com:username/myproject.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "upstream"]
url = git@github.com:projectowner/project.git
fetch = +refs/heads/*:refs/remotes/upstream/*
[remote "origin"]
url = git@github.com:yourfork/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
$ git cherry-pick dae86e1
$ git cherry-pick dae86e1
$ git pull --rebase=preserve
$ git cherry-pick dae86e1
$ git pull --rebase=preserve
git branch -r | awk "{print substr($1,8)}" | \
egrep -v -f /dev/fd/0 <(git branch) | \
awk "{print $1}" | xargs git branch -D
[alias]
# edit last commit
amend = commit --amend -C HEAD
# cancel last local commit
undo = reset --soft HEAD^
# rapid checkup
changes = diff --name-status
dic = diff --cached
diffstat = diff --stat
# condensed logs
hist = log --pretty=oneline --abbrev-commit --graph --decorate
lg = log --graph --pretty=tformat:\"%Cred%h%Creset -%C(cyan)%d %Creset%s %Cgreen(%an %cr)%Creset\" --abbrev-commit --date=relative
st = status
# show changes since last pull
lc = !git log ORIG_HEAD.. --stat --no-merges
# add modified files to commit
addm = !git ls-files -m -z | xargs -0 git-add && git status
# add new files to commit
addu = !git ls-files -o --exclude-standard -z | xargs -0 git-add && git status
# delete files marked as suppressed
rmm = !git ls-files -d -z | xargs -0 git-rm && git status
# open on textMate last uncommited files
mate = !git ls-files -m -z | xargs -0 mate
mateall = !git ls-files -m -o --exclude-standard -z | xargs -0 mate
# open on vi last uncommited files
vi = !vi $(git ls-files -m -z)
viall = !vi $(git ls-files -m -o --exclude-standard -z)
# show all users that did commit
who = shortlog -sne
[alias]
# edit last commit
amend = commit --amend -C HEAD
# cancel last local commit
undo = reset --soft HEAD^
# rapid checkup
changes = diff --name-status
dic = diff --cached
diffstat = diff --stat
# condensed logs
hist = log --pretty=oneline --abbrev-commit --graph --decorate
lg = log --graph --pretty=tformat:\"%Cred%h%Creset -%C(cyan)%d %Creset%s %Cgreen(%an %cr)%Creset\" --abbrev-commit --date=relative
st = status
# show changes since last pull
lc = !git log ORIG_HEAD.. --stat --no-merges
# add modified files to commit
addm = !git ls-files -m -z | xargs -0 git-add && git status
# add new files to commit
addu = !git ls-files -o --exclude-standard -z | xargs -0 git-add && git status
# delete files marked as suppressed
rmm = !git ls-files -d -z | xargs -0 git-rm && git status
# open on textMate last uncommited files
mate = !git ls-files -m -z | xargs -0 mate
mateall = !git ls-files -m -o --exclude-standard -z | xargs -0 mate
# open on vi last uncommited files
vi = !vi $(git ls-files -m -z)
viall = !vi $(git ls-files -m -o --exclude-standard -z)
# show all users that did commit
who = shortlog -sne
[alias]
# edit last commit
amend = commit --amend -C HEAD
# cancel last local commit
undo = reset --soft HEAD^
# rapid checkup
changes = diff --name-status
dic = diff --cached
diffstat = diff --stat
# condensed logs
hist = log --pretty=oneline --abbrev-commit --graph --decorate
lg = log --graph --pretty=tformat:\"%Cred%h%Creset -%C(cyan)%d %Creset%s %Cgreen(%an %cr)%Creset\" --abbrev-commit --date=relative
st = status
# show changes since last pull
lc = !git log ORIG_HEAD.. --stat --no-merges
# add modified files to commit
addm = !git ls-files -m -z | xargs -0 git-add && git status
# add new files to commit
addu = !git ls-files -o --exclude-standard -z | xargs -0 git-add && git status
# delete files marked as suppressed
rmm = !git ls-files -d -z | xargs -0 git-rm && git status
# open on textMate last uncommited files
mate = !git ls-files -m -z | xargs -0 mate
mateall = !git ls-files -m -o --exclude-standard -z | xargs -0 mate
# open on vi last uncommited files
vi = !vi $(git ls-files -m -z)
viall = !vi $(git ls-files -m -o --exclude-standard -z)
# show all users that did commit
who = shortlog -sne
[alias]
# edit last commit
amend = commit --amend -C HEAD
# cancel last local commit
undo = reset --soft HEAD^
# rapid checkup
changes = diff --name-status
dic = diff --cached
diffstat = diff --stat
# condensed logs
hist = log --pretty=oneline --abbrev-commit --graph --decorate
lg = log --graph --pretty=tformat:\"%Cred%h%Creset -%C(cyan)%d %Creset%s %Cgreen(%an %cr)%Creset\" --abbrev-commit --date=relative
st = status
# show changes since last pull
lc = !git log ORIG_HEAD.. --stat --no-merges
# add modified files to commit
addm = !git ls-files -m -z | xargs -0 git-add && git status
# add new files to commit
addu = !git ls-files -o --exclude-standard -z | xargs -0 git-add && git status
# delete files marked as suppressed
rmm = !git ls-files -d -z | xargs -0 git-rm && git status
# open on textMate last uncommited files
mate = !git ls-files -m -z | xargs -0 mate
mateall = !git ls-files -m -o --exclude-standard -z | xargs -0 mate
# open on vi last uncommited files
vi = !vi $(git ls-files -m -z)
viall = !vi $(git ls-files -m -o --exclude-standard -z)
# show all users that did commit
who = shortlog -sne
Bonus : cheat sheet
Voir nos autres formations sur : masterclass.les-tilleuls.coop