Github cheat sheet

    Hello, Habr! Once again, a very interesting repository caught my eye . This cheat sheet for the most secret and functional features of Git and GitHub appeared due to the speeches of Zach Holman, one of the articles of which I already translated Git and GitHub Secrets at Aloha Ruby Conference 2012 and More Git and GitHub Secrets at WDCNZ 2013. It is worth saying that the project scored over 1000 olds in less than 12 hours. I will give some examples:

    Hub - Git Wrapper


    Hub is a wrapper over Git that reduces the time spent on extra keystrokes when working with Git.
    $ hub clone tiimgreen/toc
    > git clone https://github.com/tiimgreen/toc.git
    

    On hub, you can make an alias git and everything will look even more convenient:
    # Remote
    $ git remote add rtomayko
    > git remote add rtomayko git://github.com/rtomayko/CURRENT_REPO.git
    #Fetch
    $ git fetch mislav
    > git remote add mislav git://github.com/mislav/REPO.git
    #Fork
    $ git fork
    [ repo forked on GitHub ]
    > git remote add -f YOUR_USER git@github.com:YOUR_USER/CURRENT_REPO.git
    



    Previous thread


    To go to the previous directory, we use:
    $ cd -
    

    Similarly, you can switch between branches in Git:
    $ git checkout -
    # Switched to branch 'master'
    $ git checkout -
    # Switched to branch 'next'
    $ git checkout -
    # Switched to branch 'master'
    


    Closing Issues with Commits


    To do this, in the commit, you need to specify the Issue number and add the word with the same root as fix / fixes / fixed or close / closes / closed:
    $ git commit -m "Fix cock up, fixes #12"
    

    image

    Checking out pull requirements


    If you want to do a checkout for pull requests, you first need to pick it up:
    $ git fetch origin '+refs/pull/*/head:refs/pull/*'
    

    Then checkout itself:
    $ git checkout refs/pull/42
    


    View a specific author’s commit history


    To do this, add the parameter ? Author = username to the URL:
    https://github.com/rails/rails/commits/master?author=dhh
    


    Stylized Git Log


    $ git log --all --graph --decorate --oneline --abbrev-commit
    

    image

    Git query


    Git Query allows you to find previous commits by messages, where "query" is the phrase you are looking for:
    $ git show :/query
    


    And a whole bunch of different secrets on github-cheet-sheet .

    Thank you all for your attention.

    Also popular now: