Tahák s příkazy Git

Git sleduje změny souborů jako řadu commitů v repozitáři. Tyto příkazy pokrývají každodenní tok: založení repo, uložení práce, větve, sloučení a sdílení se vzdáleným. Nechte si tahák otevřený při učení.

Aktualizováno:

PříkazCo dělá
git initCreate a new, empty Git repository in the current directory.
git cloneDownload a remote repository and its full history to your machine.
git statusShow changed, staged and untracked files in the working tree.
git addStage changes (files) to be included in the next commit.
git commitRecord staged changes as a new commit with a message.
git logDisplay the commit history of the repository.
git diffShow unstaged or staged differences between states.
git branchList, create or delete branches in the repository.
git checkout / switchSwitch branches or restore files (switch is the modern command).
git mergeJoin another branch's history into the current branch.
git rebaseReapply commits on top of another base commit, rewriting history.
git pullFetch from a remote and merge the changes into the current branch.
git pushUpload local commits to a remote repository.
git stashTemporarily shelve uncommitted changes to reapply later.
git remoteManage the set of remote repositories you track.

Poznámky

Časté dotazy

Jaký je rozdíl mezi merge a rebase?
Merge spojuje historie novým commitem se dvěma rodiči. Rebase přehraje tvé commity na jinou větev, čímž vznikne lineární historie, ale přepíší se ID commitů.
Jak vrátím commit zpět?
Použij 'git revert <commit>' pro přidání nového commitu, který změnu vrací (bezpečné, sdílená historie zůstává). 'git reset' přepisuje historii a na sdílených větvích se nepoužívá.
Jaký je rozdíl mezi git pull a git fetch?
Fetch stáhne commity a referenční body z remote bez zásahu do pracovního stromu. Pull udělá fetch a následně tyto změny slije nebo rebasuje do tvé aktuální větve.
Kdy použít git stash?
Stash dočasně odloží necommitnuté změny, abys mohl čistě přepnout větev nebo stáhnout, a pak je obnovíš příkazem 'git stash pop'.