This content originally appeared on DEV Community and was authored by Harish .R
- git rebase Reapplies commits on top of another base tip.
Used for cleaner history compared to merge.
bash
Copy
Edit
git rebase main
Interactive rebase (edit, squash, reorder commits):
bash
Copy
Edit
git rebase -i HEAD~5
- git cherry-pick Apply a specific commit from one branch onto another.
bash
Copy
Edit
git cherry-pick
- git stash Temporarily save uncommitted changes without committing them.
Save changes:
bash
Copy
Edit
git stash
Apply last stash:
bash
Copy
Edit
git stash apply
See stash list:
bash
Copy
Edit
git stash list
- git reflog Shows the history of all HEAD movements.
Useful to recover lost commits.
bash
Copy
Edit
git reflog
- git reset Undo commits.
Soft reset (keep changes staged):
bash
Copy
Edit
git reset --soft HEAD~1
Mixed reset (unstage changes):
bash
Copy
Edit
git reset --mixed HEAD~1
Hard reset (destroy changes):
bash
Copy
Edit
git reset --hard HEAD~1
- git bisect Binary search through commits to find which commit introduced a bug.
bash
Copy
Edit
git bisect start
git bisect bad
git bisect good
- git blame Show who made each change to a file.
bash
Copy
Edit
git blame
- git clean Remove untracked files from the working directory.
Dry run (show what would be deleted):
bash
Copy
Edit
git clean -n
Actually delete:
bash
Copy
Edit
git clean -f
- git tag Mark specific points in history as important (like releases).
Create lightweight tag:
bash
Copy
Edit
git tag v1.0
Create annotated tag:
bash
Copy
Edit
git tag -a v1.0 -m "Release version 1.0"
- git submodule Manage repositories inside repositories.
Add submodule:
bash
Copy
Edit
git submodule add
Initialize submodules:
bash
Copy
Edit
git submodule init
git submodule update
- git log --graph --oneline --all Visualize the repository history in a tree format.
bash
Copy
Edit
git log --graph --oneline --all
- git diff Show changes between commits, branches, or working directory.
Compare working directory to staging:
bash
Copy
Edit
git diff
Compare two branches:
bash
Copy
Edit
git diff branch1..branch2
This content originally appeared on DEV Community and was authored by Harish .R

Harish .R | Sciencx (2025-04-28T17:52:59+00:00) ML workshop day2. Retrieved from https://www.scien.cx/2025/04/28/ml-workshop-day2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.