Thursday, February 25, 2016

Git Cheat Sheet

  • Cloning a repository
           git clone <repository url> 

Commit and Push
  • Current status of staged and changed file including new additions
     git status
  • Add all changed files to staged
     git add .
  • Committing changes  
            git commit -m "commit commment"

  • Show commit details
     git show <commit-id> --stat


  • Stash Changes
     git stash

  • List stashed changes
     git stash list
  • Apply stashed  changes (Will apply the latest stash)
     git statsh apply 
  • Apply with stash id
     git stash apply <stash id>

  • Listing all branch
           git branch --all

  • Making another branch current
          git checkout <branch_name>
  • Removing a branch locally when remote branch is deleted     
     git remote prune origin


  • Diff with immediate ancestor
    git diff <change_set>^ <change_set>


  • Merging from master to a branch
            git checkout master   
     git pull     - Make sure master has all changes
     git checkout <branch>
     git merge master

No comments:

Post a Comment