Example: quiz answers

Git Cheat Sheet

Git Cheat SheetCreateFrom existing repoFrom existing datacd ~/projects/myprojectgit initgit add . git clone ~/existing/repo ~/new/repogit clone clone git command --helpGlobal Git configuration is stored in $HOME/.gitconfig (git config --help) Files changed in working directoryShowA specific file from a specific $IDChanges to tracked filesgit statusgit diff git show $id:$fileAll local branchesgit branchHistory of changesgit log Who changed what and when in a filegit blame $file What changed between $ID1 and $ID2git diff $id1 $id2 History of changes for file with diffsgit log -p $file $dir/ec/tory/A commit identified by $IDgit show $idRevertRevert the last commitgit revert HEAD Revert specific commitgit revert $id Checkout the $id version of a filegit checkout $id $file!

Git Cheat Sheet Create From existing repo From existing data cd ~/projects/myproject git init git add . git clone ~/existing/repo ~/new/repo git clone git://host.org/project.git

Tags:

  Sheet, Teach, Git cheat sheet

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Git Cheat Sheet

1 Git Cheat SheetCreateFrom existing repoFrom existing datacd ~/projects/myprojectgit initgit add . git clone ~/existing/repo ~/new/repogit clone clone git command --helpGlobal Git configuration is stored in $HOME/.gitconfig (git config --help) Files changed in working directoryShowA specific file from a specific $IDChanges to tracked filesgit statusgit diff git show $id:$fileAll local branchesgit branchHistory of changesgit log Who changed what and when in a filegit blame $file What changed between $ID1 and $ID2git diff $id1 $id2 History of changes for file with diffsgit log -p $file $dir/ec/tory/A commit identified by $IDgit show $idRevertRevert the last commitgit revert HEAD Revert specific commitgit revert $id Checkout the $id version of a filegit checkout $id $file!

2 !you cannot undo a hard resetReturn to the last committed stategit reset --hardFix the last commitgit commit -a --amend (after editing the broken files)Creates a new commitCreates a new commitBranchMerge branch1 into branch2git checkout $branch2git merge branch1 Create branch named $branch based on the HEADgit branch $branchSwitch to the $id branchgit checkout $idCreate branch $new_branch based on branch $other and switch to itgit checkout -b $new_branch $otherDelete branch $branchgit branch -d $branchCommit all your local changesPublishgit commit -aPrepare a patch for other developersgit format-patch origingit pushPush changes to originMark a version / milestonegit tag (complete conflict diff)(star '*' marks the current branch)Pull latest changes from origingit pull(does a fetch followed by a merge)Fetch latest changes from originUpdategit fetch(but this does not merge them).

3 (in case of a conflict, resolve and use git am --resolved )Apply a patch that some sent yougit am -3 regressionsgit bisect startgit bisect good $idgit bisect bad $idgit bisect bad/goodgit bisect visualizegit bisect resetCheck for errors and cleanup repositorygit fsckgit gc --pruneSearch working directory for foo()git grep "foo()"To view the merge conclictsgit add $conflicting_filegit rebase --continuePUBLISHCOMMIT commitREVERTBRANCHBROWSEUPDATECREATE statuslogshowdiffbranchresetcheckoutreve rtpullfetchmergeampushinitclonecheckoutC ommands SequenceCHANGEthe curves indicate that the command on the right is usuallyexecuted after the command on the left. This gives an idea ofthe flow of commands someone usually does with Sheet NotationUseful Commands RusinBased on the work of:S bastien PierreXprima Basicsgit reset --hardgit rebase --skipgit diffgit diff --base $filegit diff --ours $filegit diff --theirs $fileAfter resolving conflicts, merge withTo discard conflicting patchResolve Merge Conflicts(against base file)(against your changes)(against other changes)(do for all resolved files)(to start)($id is the last working version)($id is a broken version)(to mark it as bad or good)(once you're done)(to launch gitk and mark it)$id : notation used in this Sheet to represent either a commit id, branch or a tag name$file : arbitrary file name$branch : arbitrary branch namemaster.

4 Default development branchorigin : default upstream repositoryHEAD : current branchHEAD^ : parent of HEADHEAD~4 : the great-great grandparent of HEAD


Related search queries