Understanding some useful GIT commands.

Stashing in GIT

Stashing all modified files

git stash
git stash push

Fetching last stashed files and directories

git stash apply
git stash pop

Checking all last stashed files and directories

git stash show

Checking all stashes in queue

git stash list
stash@{0}: WIP on feature/TE-4312: 61307eaca last commit message on feature/TE-4312 branch
stash@{1}: WIP on feature/TE-4513: bba77bd0a last commit message on feature/TE-4513 branch
stash@{2}: WIP on feature/TE-1234: dc42acaf1 last commit message on feature/TE-1234 branch

Fetching older stash files

git stash pop {stash-id}

Stashing specific file

git stash push {filepath}

Stashing multiple files

git stash push {filepath1} {filepath2} ... {filepathN}

Clearing stash queue

git stash clear

Resetting branch

Hard resetting

git reset --hard {commit-id}
git reset --hard HEAD
git reset --hard HEAD^

Soft resetting

git reset --soft {commit-id}

Mixed resetting

git reset --mixed {commit-id}
git reset {commit-id}

Reverting commit

git revert {commit-id}

Fetching remote branches

git fetch --all

Removing unwanted files

Removing untracked files

git clean -d -i

Removing untracked files from a directory

git clean -d -n {src}

Removing ignored files

git clean -d -n -X




Full stack developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Optimization of LinkedIn Profile for New Developers

Work Experience Acknowledgment in Data Science

2nd Year 1st semester Software Engineering Undergraduate Experience at University of Kelaniya.

OSCP Hazırlık Rehberi 7

Simple Retrofit Android Tutorial

TheRailMap 1.1! Location, Feature Information, and More!

Can MongoDB really deliver ACID?

GRPC Nullable Field

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rohan Aggarwal

Rohan Aggarwal

Full stack developer

More from Medium

Version Control Git

Everything about git commands 👨‍💻️

Force merge in Git

Trackpad gestures on MacOS in Java