diff --git a/README.md b/README.md index db4e0cd..3350d3d 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,27 @@ -Git Cheat Sheet -=============== - -This is a comprehensive cheat sheet for daily work with `Git`. - -![Cheat Sheet Type](https://img.shields.io/badge/cheat%20sheet-git-orange.svg) -![Cheat Sheet Type](https://img.shields.io/badge/license-cc--by--sa--3.0-blue.svg) -![GitHub tag](https://img.shields.io/github/tag/pixelbrackets/git_cheat_sheet.svg) - -[![Preview](https://pixelbrackets.github.io/git_cheat_sheet/card.png)](https://pixelbrackets.github.io/git_cheat_sheet/) - -Usage ------ - -A webview of the cheat sheet is available at - -* https://pixelbrackets.github.io/git_cheat_sheet/ - -A PDF to print out is available at - -* https://pixelbrackets.github.io/git_cheat_sheet/git_cheat_sheet.pdf - -The cheat sheet is [written in Markdown](https://github.com/pixelbrackets/git_cheat_sheet/blob/master/git_cheat_sheet.md) -and converted to HTML & PDF on every tagged release. - -Source ------- - -https://github.com/pixelbrackets/git_cheat_sheet - -License -------- - -Creative Commons Attribution ShareAlike 3.0 (CC-BY-SA 3.0) - -The Creative Commons License can be found at https://creativecommons.org/licenses/by-sa/3.0/ - -Author ------- - -Dan Untenzu ( / [@pixelbrackets](https://github.com/pixelbrackets)) - -Contribution ------------- - -This documentation is Open Source, so please use, patch, extend or fork it. - -I welcome every [Pull Request](https://github.com/pixelbrackets/git_cheat_sheet/pulls). +Build +===== + +* Convert Markdown to HTML using https://gist.github.com/pixelbrackets/5046331 + * `./gfm2html.sh git_cheat_sheet.md screen.css > index.html` + * Remove unwanted whitespace: ` ` → `` + * Remove nofollow directive: ` rel="nofollow"` → ` ` + * Insert OpenGraph metatags + + Git Cheat Sheet + + + + + + + + + + + + +* Convert HTML to PDF using Chromium without page borders + * `chromium-browser index.html` + * Save as git_cheat_sheet.pdf +* Push to Github +* Tag new release diff --git a/card.png b/card.png new file mode 100644 index 0000000..2c6506f Binary files /dev/null and b/card.png differ diff --git a/git_cheat_sheet.md b/git_cheat_sheet.md deleted file mode 100644 index dba2b03..0000000 --- a/git_cheat_sheet.md +++ /dev/null @@ -1,470 +0,0 @@ -# Git Cheat Sheet - -* Legend: `<>` required, `[]` optional - -## Common Terminology - -* commit ≙ object with annotated changes in relation other commits -* branch ≙ collection of commits -* stage ≙ files earmarked for the next commit -* HEAD ≙ reference to the top commit in the current branch -* remote = bookmark for a repository origin (a repository may have several remotes) - -## Create & Clone - -* Clone an existing repository - - git clone [folder] - - _Default protocoll is SSH, eg. »git@example.com:repo.git«. HTTPS would be »https://example.com/repo.git«, another local repo »/home/user/repo.git«_ - - _Creates a subfolder with the repo, if the folder name is not given, then the repo name is used (»foo.git« = »./foo« subfolder)_ - -* Create a new local repository - - git init - - _If a folder name is given, a subfolder is created, otherwise the current folder is used_ - -* Send existing local repository to remote - - git remote add origin && git push - -* Special: Create an empty repository on a remote server - - _Connect with the remote server first_ - - mkdir .git && cd .git && git init --bare - - _The remote repository has to be »bare« (does not contain a working filetree, but a special .git subdirectory only) in order to accept a push_ - -## Show changes - -* Show working status - show current branch name and changed or new files - - git status - - _Hint: Set a short alias for often used commands, like `git st` for `git status` → see »Configuration«_ - -* Difference between HEAD and files not yet staged - - git diff - - _Note: This ignores new files = files which were not added to the repository yet and therefore arent »tracked«_ - -* Difference between HEAD and staged files - - git diff --cached - -* Difference between HEAD and all files (staged and not staged) - - git diff HEAD - -* Difference between branches, two commits, etc - - git diff - - _»+« line does exist in »bar« but not in »foo«, »-« reverse_ - -* Difference to another branch and show names of changed files only - - git diff --name-status - -* Show all commits of current branch which are not merged into another branch - - git log .. --oneline - - _The reference may be a branch or a tag, note the two dots at the end_ - -* Show branches in which one commit exists - - git branch --contains - -## Show history - -* Show all commits of current branch - - git log - -* Show all commits of current branch and names of each changed file - - git whatchanged - -* Show commits and each difference for a specific file - - git log -p - -* Examination: Show who changed what and when in a file - - git blame - - _Left side shows the last commit ID for the content on the right side_ - -* Show a single commit and its differences - - git show - -* Show all commits with a certain word in the commit message - - git log --grep= - -## Commit - -* Stage all (even untracked) files - - git add -A - -* Stage a tracked and modified file - - git add - -* Add hand-picked changes in a file to the next commit (≙ partial commit) - - git add -p - - `y` _Yes, add this part to the next commit_ - `n` _No, skip this part_ - `d` _Don’t add this and all remaining parts of the file_ - `s` _Try to split the current part into smaller ones_ - `e` _Manually edit the part_ - -* Stage all changes in tracked files and start a commit - - git commit -a - -* Commit all previously staged changes - - git commit - git commit -m "" - -## Branches - -* List local branches - - git branch - - _`*` marks the current branch_ - -* List remote branches - - git branch -r - - _use `-a` to show local and remote branches at once_ - -* Switch to a different branch - - git checkout - git checkout -t / - - _`-t` checkout a new branch based on remote branch and save their connection_ - -* Create a new branch based on HEAD - - git branch - - _use `git checkout -b ` to create a branch and switch right into it_ - -* Create a new branch based on a remote branch - - git branch --track / - - _use `--no-track` to create a new branch based on a remote branch, but don't save a connection between both_ - -* Connect a remote branch with a local branch - - git branch --track / - -* Show merged branches - - git branch -a --merged - - _`--no-merged` will show branches not merged yet_ - -* Delete a local branch - - git branch -d - - _`-d` will only delete the branch if it is merged with its remote branch (if set), `-D` will force the deletion_ - -* Delete a remote branch - - git push : - -## Tags - -Use tags to save a specific version (the commit relations up to this point) of a project. Merging older commits into the branch afterwards hence wont affect the tag. - -* Show all tags - - git tag -n - - _`-l` will show tag names only, `-n` will add a number of lines from the annotation (default is one)_ - -* Mark the current commit with a tag - - git tag -m "" - - _Hint: Use semantic version numbers as tags_ - -## Update - -* Download all changes from , but don't merge to HEAD yet - - git fetch - - _A manual merge is required now_ - -* Download changes and directly merge to HEAD - - git pull [ ] - - _If the connection between remote & local branch is saved, then `git pull` is sufficient_ - -* List all currently configured remote repositories - - git remote -v - -* Show information about a remote, eg. which branches exist in this remote - - git remote show - -* Remove stale remote branch trackings (outdated connections) - - git remote prune - - _Remove connections to branches deleted on the remote by now - does not delete the local branch_ - -* Add a new remote repository - - git remote add - -## Publish - -* Push local branch or tag to remote - - git push [ ] - - _use »-u« to push the branch and automatically save the connection between local & remote_ - -* Push all local branches to remote - - git push --all - -* Push all tags to remote - - git push --tags - -## Merge - -* Merge a branch into your current HEAD - - git merge - -* Manually solve conflicts and mark file as resolved - - git add && git commit -m 'Manual Merge' - -* Use a tool to solve merge conflicts - - git mergetool - - _will use tool set in »merge.tool«, use »-t « to start a custom tool_ - -* Use a merge strategy - - git merge -s recursive -X - - _»recursive« is the default merge strategy when pulling or merging one branch, so this param may be redundant_ - _»ours« merge commits but try to ignore all conflicting changes from the other branch_ - _»theirs« merge commits but try to ignore conflicts introduced by the own branch_ - _»patience« will cause GIT run rather time-consuming intelligent merge routines to avoid merge conflicts and errors in the first place_ - -* Cancel merge - - git merge --abort - -## Rebase - -Use rebase with care! It will rewrite the history and therefore requires additional efforts when working with a team! Dont rebase unless every project member knows about the required workflow! - -* Rewrite commits from HEAD until given commit - - git rebase -i - - _Opens an editable rebase command list - reorder the commands to change commit order, remove a line to delete the commit, change the preceded keyword to change the command_ - - `p|pick` _keep commit_ - `r|reword` _use commit, but edit the commit message_ - `e|edit` _use commit, but halt the rebase sequence to change the commit (use `git commit --amend -a`)_ - `s|squash` _use commit, but meld into previous commit_ - -* Rebase your current HEAD onto - - git rebase - - _Merges all commits of given branch and applies new commits of the local branch on top (creates new commit IDs for these)_ - -* Abort a rebase - - git rebase --abort - -* Continue a rebase after resolving conflicts - - git rebase --continue - -## Stash - -Use stash to save all current changes to a clipboard and retrieve them later. - -* Stash all changes away - - git stash save [comment] - -* Show all available stashes - - git stash list - - _»stash@{0}« is the rather unreadable name of the stash state, where 0 is the latest_ - -* Retrieve a state form the stash list - - git stash apply - - _default is »stash@{0}«, use `git stash pop ` to apply changes and remove the state from stash list_ - -* Remove a state from the stash list - - git stash drop - -* Remove all the stashed states - - git stash clear - -## Revert - -Git is merciful and lets you undo allmost all changes with ease. - -* Clear stage (≙ unadd files) - - git reset HEAD -- - -* Discard all changes - - git checkout -- [file] - -* Change the last commit - - git commit --amend -a - - _Replaces the last commit (new ID), so it should only be used if the modified branch was not pushed yet_ - -* Special: Change author of the last commit - - git commit --amend --author "John Doe " - -* Remove the last commit but keep all files and changes - - git reset HEAD~1 - - _Removes the last commit from the local history_ - -* Revert a commit (≙ apply inversion) - - git revert - - _Inverts changes of the given commit, applies them to the working directory and starts a new commit_ - -* Undo a local merge - - git reset --hard - - _Use only if the branch wasn't pushed yet, otherwise rebase or revert_ - -* Remove a file - - git rm --cached - - _Removes the file from the git repository index but keeps it on the file system_ - -## Configuration - -* Get configuration option - - git config
. - -* Set configuration option - - git config --local
. - - _»local« will write to ».git/config« in current repository, »global« to »~/.gitconfig» and »system« to your systems »/etc/gitconfig«_ - -* Set username and e-mail - - git config --local user.name "" && git config --local user.email - -* Ignore mode changes (chmod) - - git config --local core.filemode false - -* Set alias »st« for »status« - - git config --global alias.st status - -## Commit Message Format - - [BUGFIX] Short summary - - Optional explanatory text. Separated by new line. Wrapped to 74 chars. Written in imperative present tense ("Fix bug", not "Fixed bug"). - - Help others to understand what you did (Motivation for the change? Difference to previous version?), but keep it simple. - - Mandatory title prefix: [BUGFIX], [FEATURE] (also small additions) or [TASK] (none of the above, e.g. code cleanup). Additionall flags: [!!] (breaking change), [DB] (alter database definition), [CONF] (configuration change), [SECURITY] (fix a security issue). - - Bug tracker refs added at bottom (see http://is.gd/commit_refs). - - Resolve #42 - Ref #4 #8 #15 #16 - -_shortened, detailed example at http://is.gd/commitformat_ - -## Best practices - -* Commit related changes - * Each commit should adress one logical unit. Two different bugs should result into two commits. -* Commit early & often - * Keep your commits small and comprehensible, split large features into logical chunks. -* Test code before committing - * Make sure the code works, don't guess. Or let tools test your commit automatically. Revert faulty commits if necessary. -* Don't commit half-done work - * Commit only complete, logical changes, not half-done chunks. »Stash« changes if applicable. -* Don't commit hot files - * Don't commit configuration files (commit a config template instead), personal data, temporary files (GIT is no backup system) or things that can be regenerated form other commited things. -* Write good commit messages - * Help others to understand what you did (Motivation for the change? Whats the difference to the previous version?) - * Useless commit messages may be forwarded to whatthecommit.com -* Write in imperative present tense («change», not «changed» or «changes») - * A commit is a set of instructions for how to go from a previous state to a new state, so you should describe was the commit does and not what it did to your repository. -* Don't panic - * GIT lets you undo, fix or remove a bunch of actions -* Don't change published history - * GIT allows you to rewrite public history, but it is problematic for everyone and thus it is just not best practice to do so. -* Use branches - * Branching is cheap. Use separate branches for each bugfix, feature & idea. Make branching a part of your local workflow. -* Merge regularly - * Don't merge a huge feature into the master, instead merge the master regularly with your branch. -* Use conventions - * As with every development process: use conventions. For naming of branches and tags, how to write commit messages, when to commit into what branch, etc. - -## Sources - -* [Git Cheat Sheet by Ying Guo](https://github.com/yguo89/RTOS/wiki/Git-Cheat-Sheet) -* [Git Cheat Sheet by Git Tower](http://www.git-tower.com/files/cheatsheet/Git_Cheat_Sheet_grey.pdf) -* http://gitready.com/ -* http://git-scm.com/documentation -* http://wiki.typo3.org/CommitMessage_Format_(Git) - -## About - -* Supervisor: Dan Untenzu [@pixelbrackets](https://twitter.com/pixelbrackets) -* License: [CC-BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/de/) -* Download & Contribution: [pixelbrackets.de/git-cheat-sheet](https://pixelbrackets.de/git-cheat-sheet) diff --git a/git_cheat_sheet.pdf b/git_cheat_sheet.pdf new file mode 100644 index 0000000..bc3ee19 Binary files /dev/null and b/git_cheat_sheet.pdf differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..dbf828c --- /dev/null +++ b/index.html @@ -0,0 +1,568 @@ + + + + + Git Cheat Sheet + + + + + + + + + + + + + + +

Git Cheat Sheet

+
    +
  • Legend: <> required, [] optional
  • +
+

Common Terminology

+
    +
  • commit ≙ object with annotated changes in relation other commits
  • +
  • branch ≙ collection of commits
  • +
  • stage ≙ files earmarked for the next commit
  • +
  • HEAD ≙ reference to the top commit in the current branch
  • +
  • remote = bookmark for a repository origin (a repository may have several remotes)
  • +
+

Create & Clone

+
    +
  • +

    Clone an existing repository

    +
    git clone <URL> [folder]
    +
    +

    Default protocoll is SSH, eg. »git@example.com:repo.git«. HTTPS would be »https://example.com/repo.git«, another local repo »/home/user/repo.git«

    +

    Creates a subfolder with the repo, if the folder name is not given, then the repo name is used (»foo.git« = »./foo« subfolder)

    +
  • +
  • +

    Create a new local repository

    +
    git init <folder>
    +
    +

    If a folder name is given, a subfolder is created, otherwise the current folder is used

    +
  • +
  • +

    Send existing local repository to remote

    +
    git remote add origin <URL> && git push <remote> <branch>
    +
    +
  • +
  • +

    Special: Create an empty repository on a remote server

    +

    Connect with the remote server first

    +
    mkdir <repo>.git && cd <repo>.git && git init --bare
    +
    +

    The remote repository has to be »bare« (does not contain a working filetree, but a special .git subdirectory only) in order to accept a push

    +
  • +
+

Show changes

+
    +
  • +

    Show working status - show current branch name and changed or new files

    +
    git status
    +
    +

    Hint: Set a short alias for often used commands, like git st for git status → see »Configuration«

    +
  • +
  • +

    Difference between HEAD and files not yet staged

    +
    git diff
    +
    +

    Note: This ignores new files = files which were not added to the repository yet and therefore arent »tracked«

    +
  • +
  • +

    Difference between HEAD and staged files

    +
    git diff --cached
    +
    +
  • +
  • +

    Difference between HEAD and all files (staged and not staged)

    +
    git diff HEAD
    +
    +
  • +
  • +

    Difference between branches, two commits, etc

    +
    git diff <foo> <bar>
    +
    +

    »+« line does exist in »bar« but not in »foo«, »-« reverse

    +
  • +
  • +

    Difference to another branch and show names of changed files only

    +
    git diff <branch> --name-status
    +
    +
  • +
  • +

    Show all commits of current branch which are not merged into another branch

    +
    git log <reference>.. --oneline
    +
    +

    The reference may be a branch or a tag, note the two dots at the end

    +
  • +
  • +

    Show branches in which one commit exists

    +
    git branch --contains <commit ID>
    +
    +
  • +
+

Show history

+
    +
  • +

    Show all commits of current branch

    +
    git log
    +
    +
  • +
  • +

    Show all commits of current branch and names of each changed file

    +
    git whatchanged
    +
    +
  • +
  • +

    Show commits and each difference for a specific file

    +
    git log -p <file>
    +
    +
  • +
  • +

    Examination: Show who changed what and when in a file

    +
    git blame <file>
    +
    +

    Left side shows the last commit ID for the content on the right side

    +
  • +
  • +

    Show a single commit and its differences

    +
    git show <commit ID>
    +
    +
  • +
  • +

    Show all commits with a certain word in the commit message

    +
    git log --grep=<searchword>
    +
    +
  • +
+

Commit

+
    +
  • +

    Stage all (even untracked) files

    +
    git add -A
    +
    +
  • +
  • +

    Stage a tracked and modified file

    +
    git add <file>
    +
    +
  • +
  • +

    Add hand-picked changes in a file to the next commit (≙ partial commit)

    +
    git add -p <file>
    +
    +

    y Yes, add this part to the next commit
    +n No, skip this part
    +d Don’t add this and all remaining parts of the file
    +s Try to split the current part into smaller ones
    +e Manually edit the part

    +
  • +
  • +

    Stage all changes in tracked files and start a commit

    +
    git commit -a
    +
    +
  • +
  • +

    Commit all previously staged changes

    +
    git commit
    +  git commit -m "<message>"
    +
    +
  • +
+

Branches

+
    +
  • +

    List local branches

    +
    git branch
    +
    +

    * marks the current branch

    +
  • +
  • +

    List remote branches

    +
    git branch -r
    +
    +

    use -a to show local and remote branches at once

    +
  • +
  • +

    Switch to a different branch

    +
    git checkout <branch>
    +  git checkout -t <remote>/<remote-branch>
    +
    +

    -t checkout a new branch based on remote branch and save their connection

    +
  • +
  • +

    Create a new branch based on HEAD

    +
    git branch <new-branch>
    +
    +

    use git checkout -b <branch> to create a branch and switch right into it

    +
  • +
  • +

    Create a new branch based on a remote branch

    +
    git branch --track <new-branch> <remote>/<remote-branch>
    +
    +

    use --no-track to create a new branch based on a remote branch, but don't save a connection between both

    +
  • +
  • +

    Connect a remote branch with a local branch

    +
    git branch --track <local-branch> <remote>/<remote-branch>
    +
    +
  • +
  • +

    Show merged branches

    +
    git branch -a --merged
    +
    +

    --no-merged will show branches not merged yet

    +
  • +
  • +

    Delete a local branch

    +
    git branch -d <branch>
    +
    +

    -d will only delete the branch if it is merged with its remote branch (if set), -D will force the deletion

    +
  • +
  • +

    Delete a remote branch

    +
    git push <remote> :<remote-branch>
    +
    +
  • +
+

Tags

+

Use tags to save a specific version (the commit relations up to this point) of a project. Merging older commits into the branch afterwards hence wont affect the tag.

+
    +
  • +

    Show all tags

    +
    git tag -n
    +
    +

    -l will show tag names only, -n<num> will add a number of lines from the annotation (default is one)

    +
  • +
  • +

    Mark the current commit with a tag

    +
    git tag <tag-name> -m "<annotation>"
    +
    +

    Hint: Use semantic version numbers as tags

    +
  • +
+

Update

+
    +
  • +

    Download all changes from , but don't merge to HEAD yet

    +
    git fetch <remote>
    +
    +

    A manual merge is required now

    +
  • +
  • +

    Download changes and directly merge to HEAD

    +
    git pull [<remote> <branch>]
    +
    +

    If the connection between remote & local branch is saved, then git pull is sufficient

    +
  • +
  • +

    List all currently configured remote repositories

    +
    git remote -v
    +
    +
  • +
  • +

    Show information about a remote, eg. which branches exist in this remote

    +
    git remote show <remote>
    +
    +
  • +
  • +

    Remove stale remote branch trackings (outdated connections)

    +
    git remote prune <remote>
    +
    +

    Remove connections to branches deleted on the remote by now - does not delete the local branch

    +
  • +
  • +

    Add a new remote repository

    +
    git remote add <remote> <url>
    +
    +
  • +
+

Publish

+
    +
  • +

    Push local branch or tag to remote

    +
    git push [<remote> <branch|tag>]
    +
    +

    use »-u« to push the branch and automatically save the connection between local & remote

    +
  • +
  • +

    Push all local branches to remote

    +
    git push --all <remote>
    +
    +
  • +
  • +

    Push all tags to remote

    +
    git push --tags <remote>
    +
    +
  • +
+

Merge

+
    +
  • +

    Merge a branch into your current HEAD

    +
    git merge <branch>
    +
    +
  • +
  • +

    Manually solve conflicts and mark file as resolved

    +
    git add <resolved-file> && git commit -m 'Manual Merge'
    +
    +
  • +
  • +

    Use a tool to solve merge conflicts

    +
    git mergetool
    +
    +

    will use tool set in »merge.tool«, use »-t « to start a custom tool

    +
  • +
  • +

    Use a merge strategy

    +
    git merge -s recursive -X <ours|theirs|patience>
    +
    +

    »recursive« is the default merge strategy when pulling or merging one branch, so this param may be redundant
    +»ours« merge commits but try to ignore all conflicting changes from the other branch
    +»theirs« merge commits but try to ignore conflicts introduced by the own branch
    +»patience« will cause GIT run rather time-consuming intelligent merge routines to avoid merge conflicts and errors in the first place

    +
  • +
  • +

    Cancel merge

    +
    git merge --abort
    +
    +
  • +
+

Rebase

+

Use rebase with care! It will rewrite the history and therefore requires additional efforts when working with a team! Dont rebase unless every project member knows about the required workflow!

+
    +
  • +

    Rewrite commits from HEAD until given commit

    +
    git rebase -i <commit ID>
    +
    +

    Opens an editable rebase command list - reorder the commands to change commit order, remove a line to delete the commit, change the preceded keyword to change the command

    +

    p|pick keep commit
    +r|reword use commit, but edit the commit message
    +e|edit use commit, but halt the rebase sequence to change the commit (use git commit --amend -a)
    +s|squash use commit, but meld into previous commit

    +
  • +
  • +

    Rebase your current HEAD onto

    +
    git rebase <branch>
    +
    +

    Merges all commits of given branch and applies new commits of the local branch on top (creates new commit IDs for these)

    +
  • +
  • +

    Abort a rebase

    +
    git rebase --abort
    +
    +
  • +
  • +

    Continue a rebase after resolving conflicts

    +
    git rebase --continue
    +
    +
  • +
+

Stash

+

Use stash to save all current changes to a clipboard and retrieve them later.

+
    +
  • +

    Stash all changes away

    +
    git stash save [comment]
    +
    +
  • +
  • +

    Show all available stashes

    +
    git stash list
    +
    +

    »stash@{0}« is the rather unreadable name of the stash state, where 0 is the latest

    +
  • +
  • +

    Retrieve a state form the stash list

    +
    git stash apply <stash-name>
    +
    +

    default is »stash@{0}«, use git stash pop <stash-name> to apply changes and remove the state from stash list

    +
  • +
  • +

    Remove a state from the stash list

    +
    git stash drop <stash-name>
    +
    +
  • +
  • +

    Remove all the stashed states

    +
    git stash clear
    +
    +
  • +
+

Revert

+

Git is merciful and lets you undo allmost all changes with ease.

+
    +
  • +

    Clear stage (≙ unadd files)

    +
    git reset HEAD --
    +
    +
  • +
  • +

    Discard all changes

    +
    git checkout -- [file]
    +
    +
  • +
  • +

    Change the last commit

    +
    git commit --amend -a
    +
    +

    Replaces the last commit (new ID), so it should only be used if the modified branch was not pushed yet

    +
  • +
  • +

    Special: Change author of the last commit

    +
    git commit --amend --author "John Doe <doe@example.com>"
    +
    +
  • +
  • +

    Remove the last commit but keep all files and changes

    +
    git reset HEAD~1
    +
    +

    Removes the last commit from the local history

    +
  • +
  • +

    Revert a commit (≙ apply inversion)

    +
    git revert <commit-id>
    +
    +

    Inverts changes of the given commit, applies them to the working directory and starts a new commit

    +
  • +
  • +

    Undo a local merge

    +
    git reset --hard <merge commit ID>
    +
    +

    Use only if the branch wasn't pushed yet, otherwise rebase or revert

    +
  • +
  • +

    Remove a file

    +
    git rm --cached
    +
    +

    Removes the file from the git repository index but keeps it on the file system

    +
  • +
+

Configuration

+
    +
  • +

    Get configuration option

    +
    git config <section>.<key>
    +
    +
  • +
  • +

    Set configuration option

    +
    git config --local <section>.<key> <value>
    +
    +

    »local« will write to ».git/config« in current repository, »global« to »~/.gitconfig» and »system« to your systems »/etc/gitconfig«

    +
  • +
  • +

    Set username and e-mail

    +
    git config --local user.name "<username>" && git config --local user.email <e-mail>
    +
    +
  • +
  • +

    Ignore mode changes (chmod)

    +
    git config --local core.filemode false
    +
    +
  • +
  • +

    Set alias »st« for »status«

    +
    git config --global alias.st status
    +
    +
  • +
+

Commit Message Format

+
[BUGFIX] Short summary
+
+Optional explanatory text. Separated by new line. Wrapped to 74 chars. Written in imperative present tense ("Fix bug", not "Fixed bug").
+
+Help others to understand what you did (Motivation for the change? Difference to previous version?), but keep it simple.
+
+Mandatory title prefix: [BUGFIX], [FEATURE] (also small additions) or [TASK] (none of the above, e.g. code cleanup). Additionall flags: [!!] (breaking change), [DB] (alter database definition), [CONF] (configuration change), [SECURITY] (fix a security issue).
+
+Bug tracker refs added at bottom (see http://is.gd/commit_refs).
+
+Resolve #42
+Ref #4 #8 #15 #16
+
+

shortened, detailed example at http://is.gd/commitformat

+

Best practices

+
    +
  • Commit related changes +
      +
    • Each commit should adress one logical unit. Two different bugs should result into two commits.
    • +
    +
  • +
  • Commit early & often +
      +
    • Keep your commits small and comprehensible, split large features into logical chunks.
    • +
    +
  • +
  • Test code before committing +
      +
    • Make sure the code works, don't guess. Or let tools test your commit automatically. Revert faulty commits if necessary.
    • +
    +
  • +
  • Don't commit half-done work +
      +
    • Commit only complete, logical changes, not half-done chunks. »Stash« changes if applicable.
    • +
    +
  • +
  • Don't commit hot files +
      +
    • Don't commit configuration files (commit a config template instead), personal data, temporary files (GIT is no backup system) or things that can be regenerated form other commited things.
    • +
    +
  • +
  • Write good commit messages +
      +
    • Help others to understand what you did (Motivation for the change? Whats the difference to the previous version?)
    • +
    • Useless commit messages may be forwarded to whatthecommit.com
    • +
    +
  • +
  • Write in imperative present tense («change», not «changed» or «changes») +
      +
    • A commit is a set of instructions for how to go from a previous state to a new state, so you should describe was the commit does and not what it did to your repository.
    • +
    +
  • +
  • Don't panic +
      +
    • GIT lets you undo, fix or remove a bunch of actions
    • +
    +
  • +
  • Don't change published history +
      +
    • GIT allows you to rewrite public history, but it is problematic for everyone and thus it is just not best practice to do so.
    • +
    +
  • +
  • Use branches +
      +
    • Branching is cheap. Use separate branches for each bugfix, feature & idea. Make branching a part of your local workflow.
    • +
    +
  • +
  • Merge regularly +
      +
    • Don't merge a huge feature into the master, instead merge the master regularly with your branch.
    • +
    +
  • +
  • Use conventions +
      +
    • As with every development process: use conventions. For naming of branches and tags, how to write commit messages, when to commit into what branch, etc.
    • +
    +
  • +
+

Sources

+ +

About

+
+ + \ No newline at end of file diff --git a/screen.css b/screen.css new file mode 100644 index 0000000..5f2fac2 --- /dev/null +++ b/screen.css @@ -0,0 +1,148 @@ +/* normalize.css 2011-09-14T10:27 UTC - http://github.com/necolas/normalize.css */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}html{font-size:100%;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}body,button,input,select,textarea{font-family:"Alegreya", Palatino, Georgia, serif}a{color:#00e}a:visited{color:#551a8b}a:focus{outline:thin dotted}a:hover,a:active{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}pre,code,kbd,samp{font-family:monospace, serif;_font-family:'courier new', monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word}q{quotes:none}q:before,q:after{content:'';content:none}small{font-size:75%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}ul,ol{margin:1em 0;padding:0 0 0 40px}dd{margin:0 0 0 40px}nav ul,nav ol{list-style:none;list-style-image:none}img{border:0;-ms-interpolation-mode:bicubic}svg:not(:root){overflow:hidden}figure{margin:0}form{margin:0}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;*margin-left:-7px}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input{line-height:normal;*overflow:visible}table button,table input{*overflow:auto}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top}table{border-collapse:collapse;border-spacing:0}*{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}html{background-color:#fff;padding:0;margin:0;width:100%}body{width:100%;height:100%;padding:1em;margin:0;font-family:"Alegreya", Palatino, Georgia, serif;color:#444}a{color:#fc263a;-webkit-transition:all 0.25s;-moz-transition:all 0.25s;-o-transition:all 0.25s;transition:all 0.25s}a:hover,a:visited:hover{color:#b90314}a:visited{color:#fd717f}.content{padding:0.809em;max-width:30em;margin:auto}.content #gistid{font-weight:normal;color:#ccc;font-size:0.8em}.content #gistid a{color:#ccc;text-decoration:none}.content #gistid a:hover{text-decoration:underline}.content #description{font-family:"Alegreya SC", Palatino, Georgia, serif;font-weight:normal;font-size:2em}.content #description.loading{-webkit-animation:throb 1s infinite alternate linear;-moz-animation:throb 1s infinite alternate linear;-ms-animation:throb 1s infinite alternate linear;-o-animation:throb 1s infinite alternate linear}.content .apology{font-style:italic;color:#aaa}.content>footer{margin-top:4em;margin-bottom:2em;border-top:1px solid #eee;display:none}.content>footer.forceshow{display:block}.content>footer p{font-size:0.8em;color:#888;font-style:italic}.content>footer p .poweredby{display:inline-block;margin-right:1em}article>h1:first-child{display:none}article h1,article h2,article h3,article h4,article h5{font-weight:normal;margin-top:2em;color:black}article h1,article h2{font-size:1.5em}article h3{font-family:"Alegreya SC", Palatino, Georgia, serif;font-weight:normal;text-transform:lowercase}article h4{font-size:1em;font-style:italic}article h5{font-style:normal}article ul,article ol{list-style-position:outside;padding:0}article blockquote{margin:0;padding-left:1em;border-left:1px solid #aaa}article img,article object,article video,article audio,article figure,article iframe{max-width:100%}@media all and (min-width: 33.236em){.content{padding:1.618em;margin:0 auto;max-width:45rem;font-size:1.25em}}@media all and (min-width: 33.236em) and screen and (min-width: 30em) and (max-width: 63.236em){.content{width:30em}}@-webkit-keyframes throb{0%{opacity:0.25}100%{opacity:1}}@-moz-keyframes throb{0%{opacity:0.25}100%{opacity:1}}@-ms-keyframes throb{0%{opacity:0.25}100%{opacity:1}}@-o-keyframes throb{0%{opacity:0.25}100%{opacity:1}} + +html { + font-size: 16px; +} + +#wrapper { + column-count: 5; + column-gap: 16px; + column-rule: 1px dashed #ccc; +} + +h2:nth-of-type(1) { + color: #E62611; +} +h2:nth-of-type(2) { + color: #68C5E1; +} +h2:nth-of-type(3) { + color: #43A300; +} +h2:nth-of-type(4) { + color: #FFCE36; +} +h2:nth-of-type(5) { + color: #454545; +} +h2:nth-of-type(6) { + color: #D9831F; +} +h2:nth-of-type(7) { + color: #99356B; +} +h2:nth-of-type(8) { + color: #DD4814; +} +h2:nth-of-type(9) { + color: #76360B; +} +h2:nth-of-type(10) { + color: #90CA77; +} +h2:nth-of-type(11) { + color: #81C6DD; +} +h2:nth-of-type(12) { + color: #9E3B33; +} +h2:nth-of-type(13) { + color: #CCB647; +} +h2:nth-of-type(14) { + color: #613D2D; +} +h2:nth-of-type(15) { + color: #FF3333; +} +h2:nth-of-type(16) { + color: #666666; +} +h2:nth-of-type(17) { + color: #003333; +} + +p, h2 { + margin: 0 0 2px 0; +} + +ul, ol { + padding-left: 1.1em; + margin: 0.6em 0; +} +ul ul, ol ol { + margin-top: 0; +} + +code, pre { + padding: 0 3px 2px; + border-radius: 3px; +} +code { + padding: 3px 4px; + background-color:#f7f7f9; + border:1px solid #e1e1e8 +} +pre { + display: block; + padding: 3px; + margin: 0 0 9px; + background-color:#f5f5f5; + border: 1px solid #ccc; + border: 1px solid rgba(0,0,0,0.15); + border-radius: 4px; + white-space: pre; + white-space: pre-wrap; + word-break: break-all; + word-wrap: break-word; + break-inside: avoid; +} +pre code { + padding: 0; + color: inherit; + background-color: transparent; + border: 0 +} + +pre, code, kbd, samp { + font-size: 90%; +} + +/* Responsive ------------------------- */ + +@media (max-width: 480px) { + #wrapper { + column-count: 1; + } +} + +@media (min-width: 480px) and (max-width: 768px) { + #wrapper { + column-count: 2; + } +} + +@media (min-width: 768px) and (max-width: 1024px) { + #wrapper { + column-count: 3; + } +} + +/* Print ------------------------- */ + +@media print { + html { + font-size: 10px; + margin: 0; + } + body { + margin: 10px; + } + #wrapper { + column-count: 5; + } + + h2:nth-of-type(15) { + break-before: column; + } +}