Difference between revisions of "HowToGit"
From Lost In Wonderlands
(→useful commands) |
(→useful commands) |
||
Line 19: | Line 19: | ||
gitk --all | gitk --all | ||
− | + | === [ https://git-scm.com/docs/git-init git-init] === | |
+ | |||
git init | git init | ||
− | + | === [ https://git-scm.com/docs/git-clone git-clone] === | |
+ | |||
git clone | git clone | ||
− | + | === [https://git-scm.com/docs/git-config git-config] === | |
+ | |||
# [https://delicious-insights.com/fr/articles/configuration-git/ git attitude git config (french)] | # [https://delicious-insights.com/fr/articles/configuration-git/ git attitude git config (french)] | ||
git config --list | git config --list | ||
Line 116: | Line 119: | ||
− | + | === [https://git-scm.com/docs/git-log git-log] === | |
+ | |||
git log | git log | ||
git log -graph | git log -graph | ||
Line 124: | Line 128: | ||
git log --oneline <filePath> | git log --oneline <filePath> | ||
− | + | === [https://git-scm.com/docs/git-branch git-branch] === | |
+ | |||
git branch | git branch | ||
git branch -a | git branch -a | ||
Line 135: | Line 140: | ||
− | + | === [https://git-scm.com/docs/git-tag git-tag] === | |
+ | |||
git tag | git tag | ||
− | + | === [https://git-scm.com/docs/git-status git-status] === | |
+ | |||
git status | git status | ||
− | + | === [https://git-scm.com/docs/git-stash git-stash] === | |
+ | |||
git stash | git stash | ||
git stash pop | git stash pop | ||
− | + | === [https://git-scm.com/docs/git-fetch git-fetch] === | |
+ | |||
git fetch | git fetch | ||
− | + | === [https://git-scm.com/docs/git-pull git-pull] === | |
git pull | git pull | ||
git pull --rebase | git pull --rebase | ||
− | + | === [https://git-scm.com/docs/git-checkout git-checkout] === | |
+ | |||
git checkout | git checkout | ||
git checkout -b <branchname> | git checkout -b <branchname> | ||
− | + | === [https://git-scm.com/docs/git-merge git-merge] === | |
+ | |||
git merge | git merge | ||
− | + | === [https://git-scm.com/docs/git-rebase git-rebase] === | |
+ | |||
get rebase | get rebase | ||
git rebase -i | git rebase -i | ||
Line 166: | Line 178: | ||
− | + | === [https://git-scm.com/docs/git-cherry-pick git-cherry-pick ] === | |
+ | |||
git cherry-pick <commit sha1> | git cherry-pick <commit sha1> | ||
git cherry-pick --abort | git cherry-pick --abort | ||
− | + | === [https://git-scm.com/docs/git-rerere git-rerere ] === | |
+ | |||
git rerere can be activated and set to be used automatically by git rebase | git rerere can be activated and set to be used automatically by git rebase | ||
− | + | === [https://git-scm.com/docs/git-reflog git-reflog] === | |
+ | |||
git reflog | git reflog | ||
− | + | === [https://git-scm.com/docs/git-diff git-diff] === | |
+ | |||
git diff | git diff | ||
git diff <filePath> | git diff <filePath> | ||
− | + | === [https://git-scm.com/docs/git-difftool git-difftool] === | |
+ | |||
git difftool | git difftool | ||
git difftool <filePath> | git difftool <filePath> | ||
− | + | === [https://git-scm.com/docs/git-mergetool git-mergetool] === | |
+ | |||
git mergetool | git mergetool | ||
− | + | === [https://git-scm.com/docs/git-reset git-reset] === | |
+ | |||
git reset | git reset | ||
− | + | === [https://git-scm.com/docs/git-add git-add] === | |
+ | |||
git add | git add | ||
git add -a | git add -a | ||
git add -p | git add -p | ||
− | + | === [https://git-scm.com/docs/git-rm git-rm] === | |
+ | |||
git rm | git rm | ||
− | + | === [https://git-scm.com/docs/git-mv git-mv] === | |
+ | |||
git mv | git mv | ||
− | + | === [https://git-scm.com/docs/git-grep git-grep] === | |
+ | |||
git grep | git grep | ||
− | + | === [https://git-scm.com/docs/git-commit git-commit] === | |
+ | |||
git commit | git commit | ||
git commit -m "commit message text" | git commit -m "commit message text" | ||
Line 211: | Line 235: | ||
git commit --amend | git commit --amend | ||
− | + | === [https://git-scm.com/docs/git-push git-push] === | |
git push | git push | ||
git push origin nomBranche | git push origin nomBranche | ||
− | + | === [https://git-scm.com/docs/git-stash git-stash] === | |
+ | |||
git stash | git stash | ||
git stash pop | git stash pop | ||
Line 221: | Line 246: | ||
git stash applymvnc | git stash applymvnc | ||
− | + | === [https://git-scm.com/docs/git-stash git-reset] === | |
+ | |||
git reset --hard origin/<myRemoteBranch> | git reset --hard origin/<myRemoteBranch> | ||
− | + | === [https://git-scm.com/docs/git-alias git-alias] === | |
+ | |||
alias: | alias: | ||
git config --global alias.newCommand 'Commande en entier sans le "git"' | git config --global alias.newCommand 'Commande en entier sans le "git"' | ||
Line 234: | Line 261: | ||
git config --global alias.cp 'cherry-pick' | git config --global alias.cp 'cherry-pick' | ||
− | + | === [https://git-scm.com/docs/git-bisect git-bisect] === | |
+ | |||
git bisect | git bisect | ||
− | + | === [https://git-scm.com/docs/git-blame 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) | 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) | ||
Revision as of 13:30, 6 May 2019
Contents
- 1 How To Git
- 1.1 See also
- 1.2 useful commands
- 1.2.1 [ https://git-scm.com/docs/git-init git-init]
- 1.2.2 [ https://git-scm.com/docs/git-clone git-clone]
- 1.2.3 git-config
- 1.2.4 git-log
- 1.2.5 git-branch
- 1.2.6 git-tag
- 1.2.7 git-status
- 1.2.8 git-stash
- 1.2.9 git-fetch
- 1.2.10 git-pull
- 1.2.11 git-checkout
- 1.2.12 git-merge
- 1.2.13 git-rebase
- 1.2.14 git-cherry-pick
- 1.2.15 git-rerere
- 1.2.16 git-reflog
- 1.2.17 git-diff
- 1.2.18 git-difftool
- 1.2.19 git-mergetool
- 1.2.20 git-reset
- 1.2.21 git-add
- 1.2.22 git-rm
- 1.2.23 git-mv
- 1.2.24 git-grep
- 1.2.25 git-commit
- 1.2.26 git-push
- 1.2.27 git-stash
- 1.2.28 git-reset
- 1.2.29 git-alias
- 1.2.30 git-bisect
- 1.2.31 git-blame
- 1.3 How-To
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