Git Cheatsheet

Photo by Yancy Min on Unsplash

Git Cheatsheet

·

2 min read

Git is an open source version control system. Listed are basic cheatsheet of most commonly used git commands.

Git Configuration

  • Set the name
    $ git config --global user.name "User name"
    
  • Set the email
    $ git config --global user.email "usersemail@gmail.com"
    
  • Set default editor
    $ git config --global core.editor Vim
    
  • Check the config list
    $ git config -list
    

    Starting Project

  • git init : Create a local repository
    $ git init
    
  • git clone : Make a copy from server repository
    $   git clone <repository name>
    

    Local changes

  • git add : Add file to staging area
    $  git add <filename>
    
  • git commit : creates a version history with message
    $  git commit -m " Commit Message"
    

    Track Changes

  • git status : gives the status of working and staging area.
    $  git status
    

    Commit History

  • git log : shows the commit history with message and timestamp
    $  git log
    

    Remote

  • git remote add : add remote for repository
    $  git remote add <remote repo name>
    
  • git push : push data to remote server
    $  git push origin master
    
  • git pull : push data from remote server
    $  git pull origin master
    
    Happy Learning :)