DEV Community

Harish .R
Harish .R

Posted on

ML workshop day2

  1. 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

  1. git cherry-pick Apply a specific commit from one branch onto another.

bash
Copy
Edit
git cherry-pick

  1. 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

  1. git reflog Shows the history of all HEAD movements.

Useful to recover lost commits.

bash
Copy
Edit
git reflog

  1. 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

  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

  1. git blame Show who made each change to a file.

bash
Copy
Edit
git blame

  1. 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

  1. 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"

  1. 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

  1. git log --graph --oneline --all Visualize the repository history in a tree format.

bash
Copy
Edit
git log --graph --oneline --all

  1. 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

Top comments (0)