Skip to content

Latest commit

 

History

History
102 lines (66 loc) · 1.32 KB

commonly-used-commands.md

File metadata and controls

102 lines (66 loc) · 1.32 KB

Common Commands using git

Commit History

Show all commits, starting with the newest
git log
Commit history of specific file
git log -p <file_name>

# EXAMPLE
git log -p README.md
Commit history by user
git blame <file_name>

#Example
git blame README.md

Branches

List all local branches
git branch
List all local and remote branches
git branch -av
Switch to an existing branch
git checkout <branch_name>

# Example
git checkout jinnabalu/testBranchName
Create a new branch
git checkout -b <brach_name>

# Example
git checkout -b jinnabalu/myNewBranchName
Delete the local branch
git branch -d <branch_name>

# Example
git branch -d jinnabalu/myNewBranchName

## Force delete if not merged
git branch -D jinnabalu/myNewBranchName
Delete remote/origin branch
git push origin --delete <branch_name>

# Example
git push origin --delete jinnabalu/myNewBranchName

Pull and Push

Get the latest from remote

pull: gets latest pushed by someone to the branch

git pull
Push local changes

push: push local changes to the remote branch

git push -u origin <branch_name>

# Example
git push -u origin jinnabalu/myNewBranchName