Git parancsok gyorsreferencia

A Git a fájlváltozásokat commitok sorozataként követi nyomon egy tárolóban. Ezek a parancsok a napi munkafolyamatot fedik le: tároló indítása, munka mentése, elágaztatás, összeolvasztás és megosztás távolival. Tanuláskor tartsd nyitva ezt a gyorsreferenciát.

Frissítve:

ParancsMit csiná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.

Megjegyzések

Gyakori kérdések

Mi a különbség a merge és a rebase között?
A merge két szülővel rendelkező új commitet hoz létre az elágaztatott történetek egyesítésére. A rebase a commiteket egy másik ág tetejére játssza újra, lineáris történetet adva, de újraírja a commit-azonosítókat.
Hogyan vonjak vissza egy commitet?
Használd a 'git revert <commit>' parancsot, ami egy új commitet ad hozzá a változás visszavonására (biztonságos, megőrzi a megosztott történetet). A 'git reset' újraírja a történetet, megosztott ágakon ne használd.
Mi a különbség a git pull és a git fetch között?
A fetch letölti a commitokat és referenciákat a távolból anélkül, hogy érintené a munkafát. A pull fetch-tel kezd, majd beolvasztja vagy rebase-eli a változásokat az aktuális ágba.
Mikor érdemes a git stash-t használni?
A stash ideiglenesen félrerakja a nem commitolt változásokat, így tisztán válthatsz ágat vagy húzhatsz, majd a 'git stash pop' paranccsal visszaállíthatod őket.