git clone <CLONE_URL>
# Example
git clone https://github.com/JinnaBalu/GitCheatSheet.git
git init
git status
git status
git add --all
OR
git add .
git commit -am "my commit message"
a- all
m- message
git log
git log -p <file_name>
# EXAMPLE
git log -p README.md
git blame <file_name>
#Example
git blame README.md
git branch
git branch -av
git checkout <branch_name>
# Example
git checkout jinnabalu/testBranchName
git checkout -b <brach_name>
# Example
git checkout -b jinnabalu/myNewBranchName
git branch -d <branch_name>
# Example
git branch -d jinnabalu/myNewBranchName
## Force delete if not merged
git branch -D jinnabalu/myNewBranchName
git push origin --delete <branch_name>
# Example
git push origin --delete jinnabalu/myNewBranchName
pull: gets latest pushed by someone to the branch
git pull
push: push local cahnges to the remote branch
git push -u origin <branch_name>
# Example
git push -u origin jinnabalu/myNewBranchName
Merging changes from feature_branch to develop
- Get latest from develop and merge to feature_branch
git checkout develop
git pull
git checkout feature_branch
git merge --no-ff origin develop
Note : To be safe from conflict with develop(GOOD PRACTICE), we will resolve in feature_branch
- Merge feature_branch to develop
git checkout develop
git merge --no-ff origin feature_branch
- Soft Reset
git reset <commit_hash> --soft
- Mixed Reset
git reset <commit_hash>
#OR
git reset <commit_hash> --mixed
- Hard Reset
git reset <commit_hash> --hard
revert: inverse the changes from history and create a new commit
git revert <commit-hash>
rebase: re-write history commits in a different place
git rebase <commit-hash>
- Get count of branches
git branch -a | wc -l
- Get the commits from individual
git shortlog -s -n --all
#OR
git shortlog -s -n
- Get count the commits for the branch we are in
git rev-list --count HEAD
#OR
git log --pretty=oneline | wc -l
#OR
git rev-list --count <BRANCH_NAME>
- List of branches
git branch -a