Créée par Tony MEMBOT via l'API de présentation Reveal.js
Robin part à la chasse et tombe sur GIT
yum install git
sudo apt-get install git
http://gitforwindows.org/
sudo apt-get install gitk
git config --local [action]
git config --global [action]
git config --system [action]
git config --global user.name r.hood
git config --global user.email robin.hood@gmail.com
git config --list
git config user.email
git config --global --unset user.email
git config --global --edit
[user]
name = Tony MEMBOT
email = t.membot@tatayoyo.com
[color]
# Enable colors in color-supporting terminals
ui = auto
[url "https://github.com/"]
insteadOf = git@github.com:
insteadOf = git://github.com/
insteadOf = git+https://github.com/
insteadOf = git+ssh://git@github.com:
insteadOf = ssh://git@github.com:
insteadOf = ssh+https://git@github.com/
[pull]
# This is GREAT… when you know what you're doing and are careful
# WARNING! This option, which does away with the one gotcha of
# auto-rebasing on pulls, is only available from 1.8.5 onwards.
rebase = preserve
[difftool "sourcetree"]
cmd = 'D:/dev/bekom/apps/Perforce/p4merge.exe' -C utf8 \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = 'D:/dev/bekom/apps/Perforce/p4merge.exe' -C utf8 \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
trustExitCode = true
[status]
# Recursively traverse untracked directories to display all contents
showUntrackedFiles = all
[tag]
# Sort tags as version numbers whenever applicable, so 1.10.2 is AFTER 1.2.0.
sort = version:refname
[alias]
logall = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white) - %an%C(reset) %C(bold yellow)%d%C(reset)' --all
c = checkout
oups = commit --amend
[http]
proxy = http://proxy.ici.net:1234
[https]
proxy = http://proxy.ici.net:1234
# permet de supprimer les branches remotes obsolètes lorsqu'un fetch est réalisé.
[remote "origin"]
prune = true
git init
touch readme.txt
git status
git add readme.txt
git status
git commit -m "My first commit !"
git status
git log
git init
Note : Pour obtenir de l'aide sur une commande
git [command] --help
git status
git config --global color.status.added "green bold"
git config --global color.status.changed "red bold"
git config --global color.status.untracked "cyan bold"
git config --global status.showUntrackedFiles all
git add [filename]
git add image/\*.png
git add *.properties
git add .
git add -A
git add -p index.html
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help
git add [filename]
==
git stage [filename]
git commit
git config --global core.editor nano
git config --global commit.template ~/.template.txt
git config --global commit.status true
git commit -m "feat(section3): init section"
touch readme.txt
edit hello.txt
rm privateKey.txt
git commit -a
git log
git log --decorate=full --format=fuller
git log --oneline
git log --oneline --author Tony -n 3 --skip 1
Full
git log --grep session
git config --global format.pretty fuller
git config --global log.date relative
git log --graph --abbrev-commit --decorate --date=relative --all
--format=format:'%C(bold blue)%h%C(reset) -
%C(bold green)(%ar)%C(reset) %C(white)%s%C(reset)
%C(dim white) - %an%C(reset) %C(bold yellow)%d%C(reset)'
git config --global alias.logall "log --graph --abbrev-commit --decorate
--date=relative --all --format=format:'%C(bold blue)%h%C(reset) -
%C(bold green)(%ar)%C(reset) %C(white)%s%C(reset)
%C(dim white) - %an%C(reset) %C(bold yellow)%d%C(reset)'"
git config --global alias.ca "commit --amend"
git config --global alias.addjs "add \*.js"
.gitignore
### IntellIJ ###
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
### Java ###
*.class
*.jar
*.war
### Maven ###
target/
pom.xml.releaseBackup
pom.xml.versionsBackup
git diff
Diff par défaut (dév vs index)
git diff
Diff par défaut avec mots colorés
git diff --color-words
Diff entre le staged et le HEAD
git diff --staged
Diff entre deux commits
git diff 6813253 71ba976
Attention à l'ordre !
git diff HEAD^ HEAD
!=
git diff HEAD HEAD^
git diff [source] [target]
git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
git config --global diff.algorithm histogram
git config --global diff.algorithm patience
git checkout [filename]
git checkout -- index.html
git checkout HEAD -- index.html
git checkout 0e40D47 index.html
git checkout -- '*.html'
git reset [path]
git reset [toTargetCommit]
git reset index.html
git reset -p index.html
git reset 027def7
git reset HEAD
git reset--hard HEAD~2
git revert [TargetCommit]
git revert 0e40d47
git revert 0e40d47
git revert 0e40d47
git revert ca82cb2..0e40d47
Il se passe quoi si je commit sur master (HEAD) ?
Il se passe quoi si je commit sur feat2 ?
git branch
git branch feat1
git branch feat2 0e40d47
git branch --list
git branch --contain 300a98f
git branch -m feat1 feature1
git branch -d feature1
git branch -D feature1
git tag nomTag [branch | commit]
git tag
git tag v1.0
git tag v1.0 feat2
git checkout [branch | commit]
git checkout feat1
git checkout 2
git commit -am "I'll lost my work"
git checkout master
git checkout V1.0.0
git checkout -b feat4
git merge targetBranch
git merge feat1
git merge feat1
git merge --abort
git config merge.tool vimdiff
git mergetool
git rebase [branch | commit]
git rebase master
git rebase -i HEAD~2
Edition du fichier de travail
Modifier les messages de commit sera ignoré ici
git rebase master
git rebase feat1 feat2 --onto master
git show HEAD
git revert HEAD -m 2
git init --bare
git clone targetUrl
git clone --local /home/robin/projets/myProject
git clone https://github.com/reivon/FormationGit.git
git clone git@github.com:reivon/FormationGit.git
git clone ssh://git@example.org/~/example.git
git remote -v
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)
git remote set-url origin https://github.com/user/repo2.git
git config --local --edit
git fetch [remote]
git config --global fetch.prune true
git fetch --prune
git checkout feat1
git pull [options] [remote] [branch]
git pull origin master
git pull --rebase=true origin master
git push [options] [remote] [branch]
git push -u origin master
git push origin :myBranch
git push -d origin myBranch
git push origin feat3
git push origin master -f
git add .
git commit -m "init du projet"
git push origin master
git init
git add .
git commit -m "init du projet"
git remote add origin [remote_repository_URL]
git push origin master
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Un commit clair (atomique) peut être revert / cherry-pick / ...
git flow init
git flow feature start [nom]
git flow feature finish [nom]
git flow release start/finish [nom]
git flow hotfix start/finish [nom]
git stash [command]
# ... hack hack hack ...
$ git checkout -b my_wip
$ git commit -a -m "WIP"
$ git checkout master
$ edit emergency fix
$ git commit -a -m "Fix in a hurry"
$ git checkout my_wip
$ git reset --soft HEAD^
# ... continue hacking ...
# ... hack hack hack ...
$ git stash
$ edit emergency fix
$ git commit -a -m "Fix in a hurry"
$ git stash pop
# ... continue hacking ...
git stash push -m "temp"
git stash pop
git show [options] [object]
git show f6ef819
git show --pretty="" --name-only 7f6ce03
git show --stat 7f6ce03
git cherry-pick [options] [commit]
git cherry-pick 5397e5b
git blame [file]
git blame index.html
git blame -L 40,60 index.html
git blame --since=3.weeks -- index.html
git mv [options] [source] [dest]
$ mv LISEZMOI.txt LISEZMOI
$ git rm LISEZMOI.txt
$ git add LISEZMOI
Attention à windows ! Case sensitive
git log --follow index.html
git bisect [cmd]
mkdir git_bisect_tests
cd git_bisect_tests
git init
echo Fais > test.txt
git add -A && git commit -m "Adding the word 'Fais'"
echo dodo >> test.txt
git add -A && git commit -m "Adding the word 'dodo'"
echo colas >> test.txt
git add -A && git commit -m "Adding the word 'colas'"
echo mon >> test.txt
git add -A && git commit -m "Adding the word 'mon'"
echo petit >> test.txt
git add -A && git commit -m "Adding the word 'petit'"
echo frère >> test.txt
git add -A && git commit -m "Adding the word 'frère'"
sed -i -e 's/frère/monstre/g' test.txt
git add -A && git commit -m "Changing the word 'frère' to 'monstre'"
echo fais >> test.txt
git add -A && git commit -m "Adding the word 'fais'"
echo dodo >> test.txt
git add -A && git commit -m "Adding the word 'dodo'"
echo "stp j'en peux plus" >> test.txt
git add -A && git commit -m "Adding the true end of song"