Skip to content

Instantly share code, notes, and snippets.

@GSerjo
Created February 29, 2016 18:20
Show Gist options
  • Save GSerjo/be23c0d70e530b1a292d to your computer and use it in GitHub Desktop.
Save GSerjo/be23c0d70e530b1a292d to your computer and use it in GitHub Desktop.
Git cheat list

Git cheat list

  • remembering the password

    git config --global credential.helper store
    git fetch
    

    the first command tells git to remember the credentials that you are going to provide for the second command

  • path to the global config

    C:\Users\Bykov\.gitconfig
    
  • example of a global config

    [user]
        email = *****
        name = Aleksey Bykov
        password = *****
    [merge]
        tool = p4merge
    [mergetool "p4merge"]
        cmd = p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
        path = \"C:/Program Files/Perforce\"
        trustExitCode = false
    [push]
        default = simple
    [diff]
        tool = meld
    [difftool "p4merge"]
        cmd = p4merge.exe \"$LOCAL\" \"$REMOTE\"
        path = C:/Program Files/Perforce/p4merge.exe
    [difftool "meld"]
        cmd = \"C:/Program Files (x86)/Meld/Meld.exe\" \"$LOCAL\" \"$REMOTE\"
        path = C:/Program Files (x86)/Meld/Meld.exe
    
  • viewing differences between current and other branch

    git difftool -d BRANCH_NAME
    
  • viewing differences between current and stash

    git difftool -d stash
    
  • viewing differences between several commits in a diff tool

    git difftool -d HEAD@{2}...HEAD@{0}
    
  • view all global settings

    git config --global -l
    
  • delete tag

    git tag -d my-tag
    git push origin :refs/tags/my-tag
    
  • checking the history of a file or a folder
    git log -- <FILE_OR_FOLDER>

  • disabling the scroller
    git --no-pager <...>

  • who pushed last which branch
    git for-each-ref --format="%(committerdate) %09 %(refname) %09 %(authorname)"

  • deleting remote branch
    git push origin :<BRANCH_NAME>

  • deleting local branch
    git branch -d <BRANCH_NAME>

  • list actual remote branchs
    git ls-remote --heads origin

  • list all remote branches ever
    git branch -r

  • list all local branches
    git branch -l

  • find to which branch a given commit belongs
    git branch --contains <COMMIT>

Updating from a forked repository

git remote add upstream https://github.com/Microsoft/TypeScript.git
git fetch upstream
git rebase upstream/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment