Skip to content

Latest commit

 

History

History
247 lines (120 loc) · 2.88 KB

Learning Git.MD

File metadata and controls

247 lines (120 loc) · 2.88 KB

Git commands

Installation

Find out more
$ git --version 

Git configuration

Find out more
$ git config --global user.name "[username]" 
$ git config --global user.email "[valid-email]" 
$ git config --global color.ui auto 

Working with Local Branch

Find out more
  • Create a branch
$ git branch  

  • Display all branches
$ git branch -a 

  • Delete a branch
$ git branch -d  

  • Delete remote branch
$ git push origin –delete [branchName] 

  • Checkout an existing branch
$ git checkout  

  • Checkout and create a new branch
$ git checkout -b  

  • Merge a branch into an active branch
$ git merge  

  • Recover a deleted file and prepare it for commit
$ git checkout  

Working With Remote Repositories

Find out more
$ git remote add origin  

  • git Clone
$ git clone  

  • git push
$ git push -u origin master 

  • git push
$ git pull origin master 

  • git fetch
$ git fetch   

Working With Local Repositories

Find out more
  • Create a new Folder
$ mkdir test 

  • Initialize Git
$ cd test/ 
$ git init 

  • Create Readme file
$ cat > Readme.md 

  • Staging
$ git add . 
$ git add  

  • Check status
$ git status 

  • Committing staged files
$ git commit -m "Commit message" 

  • Remove file
$ git rm  

  • logs
$ git rm  

Additional Commands

Find out more
  • git stash
$ git stash -u 

  • brings the stashed work back to the working directory
$ git stash pop 

  • undoing changes
$ git reset  
$ git clean -n 

  • Define a tag
$ git tag  

  • git diff
$ git diff 
$ git diff --staged 
$ git diff   

Resources