October 22, 2020 · dev git cheatsheet
Git CheatSheet
Usage
- Clone Repository
Git clone URL HERE
- Initializes empty git repository
Git Init
- Get status of files that are not tracked
Git Status
- List Branches
Git branch -a
- Adds all files to commit
Git Add (*) or (.)
- Commit your files with message to indicate what you did
Git Commit -am "msg here”
- Adds a remote host
Git remote add origin "URLToRemoteHost"
- Push local git to remote origin
Git push -u origin master
- Make a new branch
Git checkout -b NameOfNewBranch
- Merge branch
Git merge NameOfBranch
- Shows Last Commits
Git log
- Delete Local Branch
Git branch -d BranchName
- Delete BranchName - Delete Remote Branch
Git push origin
- Pull master branch from remote into local
Git pull origin master
- Discard untracked changes
Git checkout -- .
Configuration
- Set Username and Email
Git config --global user.name "usernameHere"
Git config --global user.email "emailHere"