HowToGit
From Lost In Wonderlands
How To Git
NeXT Steps
here everything has yet to be done !
coming soon :
Everything You Always Wanted to Know on git [seldom]... (But Were Afraid to Ask)
a collection of links of interest
See also
useful commands
gitk gitk --all
=== [ https://git-scm.com/docs/git-init git-init] === git init
=== [ https://git-scm.com/docs/git-clone git-clone] === git clone
=== git-config === # git attitude git config (french) git config --list git config --list --show-origin
git config --global user.name "Your Name Comes Here" git config --global user.email you@yourdomain.example.com
core.whitespace true core.autocrlf true core.safecrlf true core.eol
core.symlinks false
core.whitespace true
A comma separated list of common whitespace problems to notice. git diff will use color.diff.whitespace to highlight them, and git apply --whitespace=error will consider them as errors. You can prefix - to disable any of them (e.g. -trailing-space):
blank-at-eol treats trailing whitespaces at the end of the line as an error (enabled by default).
space-before-tab treats a space character that appears immediately before a tab character in the initial indent part of the line as an error (enabled by default).
indent-with-non-tab treats a line that is indented with space characters instead of the equivalent tabs as an error (not enabled by default).
tab-in-indent treats a tab character in the initial indent part of the line as an error (not enabled by default).
blank-at-eof treats blank lines added at the end of file as an error (enabled by default).
trailing-space is a short-hand to cover both blank-at-eol and blank-at-eof.
cr-at-eol treats a carriage-return at the end of line as part of the line terminator, i.e. with it, trailing-space does not trigger if the character before such a carriage-return is not a whitespace (not enabled by default).
tabwidth=<n> tells how many character positions a tab occupies; this is relevant for indent-with-non-tab and when Git fixes tab-in-indent errors. The default tab width is 8. Allowed values are 1 to 63.
# setting editor #emacs git config --global core.editor emacs #vscode #vi, vim #nano #TextEdit # using notepad on window 64bits git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -nosession" # using notepad on window 32 bits git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession"
# TextMate : l'invocation en ligne de commande mate doit être installée (ça se fait depuis Help > Terminal Usage… dans la v1 et depuis l'onglet Terminal des Préférences dans la v2), après quoi c'est juste mate -w. #SublimeText : il faut avoir un appel en ligne de commande, là aussi. Sur OSX avec ST2, j'ai un lien symbolique /usr/local/bin/subl vers /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl, qui est fourni pour ça. Après quoi subl -w. #GEdit : gedit -w -s #GVim : gvim --nofork #Coda : Il vous faut installer coda-cli (généralement via Homebrew, toujours aussi utile…) après quoi coda -w. #Chocolat : Installez l'appel en ligne de commande (Chocolat > Install Command Line Tool…) après quoi choc -w #Notepad++ : vous aurez peut-être besoin d'adapter le chemin en fonction de là où vous avez installé Notepad++, mais voici l'idée : 'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin. #Ultra-Edit : uedit32 /fni # on macOS , depending on applications, you may have to go inside the application package
# setting diff tool git config --global core.editor emacs # P4Merge # Meld # kdiff3 # winMerge # TortoiseMerge
# setting merge tool git config --global core.editor emacs # P4Merge # Meld # kdiff3 # winMerge # TortoiseMerge
mergetool.keepBackup false mergetool.keepTemporaries false mergetool.prompt false
=== git-log === git log git log -graph git log -graph --oneline git log --oneline git log -- <filePath> git log --oneline <filePath>
=== git-branch === git branch git branch -a git branch -r
git branch -D <branchname> git branch -m newNameOfLocalBranch git branch -m branchToRename newNameOfBranchToRename git branch --set-upstream-to=origin/nomBranchRemote nomBranchLocale
=== git-tag === git tag
=== git-status === git status
=== git-stash === git stash git stash pop
=== git-fetch === git fetch
=== git-pull === git pull git pull --rebase
=== git-checkout === git checkout git checkout -b <branchname>
=== git-merge === git merge
=== git-rebase === get rebase git rebase -i git rebase --interractive --onto
=== git-cherry-pick === git cherry-pick <commit sha1> git cherry-pick --abort
=== git-rerere === git rerere can be activated and set to be used automatically by git rebase
=== git-reflog === git reflog
=== git-diff === git diff git diff <filePath>
=== git-difftool === git difftool git difftool <filePath>
=== git-mergetool === git mergetool
=== git-reset === git reset
=== git-add === git add git add -a git add -p
=== git-rm === git rm
=== git-mv === git mv
=== git-grep === git grep
=== git-commit === git commit git commit -m "commit message text" git commit -p git commit --amend
=== git-push === git push git push origin nomBranche
=== git-stash === git stash git stash pop git stash clear git stash applymvnc
=== git-reset === git reset --hard origin/<myRemoteBranch>
=== git-alias === alias: git config --global alias.newCommand 'Commande en entier sans le "git"' Exemple : git config --global alias.unstage 'reset HEAD --' Usefull ones : git config --global alias.st 'status' git config --global alias.co 'checkout' git config --global alias.cp 'cherry-pick'
=== git-bisect === git bisect
=== git-blame === git blame <filepath>, list all the changes on a file for each lines and tell which commiter did them (the name have to be set for each commiter)
How-To
- how to get a file history
git log -- <filePath> git log <filepath>
- using reflog and git reset to cancel actions
- resetting
- cancelling the last pushed commit
git revert
- cancelling the last commit (not yet pushed)
git reset HEAD~
- resetting a local branch after the remote branch on the server
git reset --hard origin/<myRemoteBranch>
- This removes everything from the index, then just run:
git rm -r --cached .
- Applying a .gitignore file added well after having committed file
git rm -r --cached . git add . git commit -m ".gitignore is now working"
- patches
- create a patch
git diff >> patch file git format-patch patch-file
** accept a patch git apply patch_file