Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
111 views

Advanced Git Commands

This document discusses various advanced Git commands for reverting changes, showing commit diffs, keeping Git history linear, squashing commits, saving the working directory, cherry-picking changes, and cleaning untracked and ignored files. Commands covered include git revert, git reset, git diff, git show, git rebase, git stash, git cherry-pick, and git clean.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Advanced Git Commands

This document discusses various advanced Git commands for reverting changes, showing commit diffs, keeping Git history linear, squashing commits, saving the working directory, cherry-picking changes, and cleaning untracked and ignored files. Commands covered include git revert, git reset, git diff, git show, git rebase, git stash, git cherry-pick, and git clean.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Git Advanced

Commands
Revert Changes - Revert

git revert <hash>

git revert --no-commit <hash>

git revert HEAD~2..HEAD

git revert -m <1,2> <hash>


Revert Changes - Reset

git reset --soft HEAD~1

git reset --hard HEAD~1

git reset --hard HEAD

git reset --hard origin/main


Showing commits diff

git diff <hash>~ <hash>

git show <hash>


Keeping the git history linear

git rebase <branch>


Squashing commits

git reset --soft HEAD~3 && git commit

git rebase -i HEAD~3


Saving the working directory

git stash

git stash pop

git stash list


Cherry-picking changes

git cherry-pick <commitSha>


Bonus, cleaning untracked and ignored files

git clean -dxf

You might also like