Skip to content

Instantly share code, notes, and snippets.

@zyadtaha
Last active October 13, 2025 10:29
Show Gist options
  • Select an option

  • Save zyadtaha/bc45f9c196abd628f6b8d02340c7e252 to your computer and use it in GitHub Desktop.

Select an option

Save zyadtaha/bc45f9c196abd628f6b8d02340c7e252 to your computer and use it in GitHub Desktop.
Git Hands-On

How to stage specific lines (not the whole file) using terminal?

git add -e <file-name>

Useful git log flags to try:

git log --oneline
git log --all --graph # very useful when checking out a commit to work based on it

How to make an alias for a command?

git config --global alias.lol "log --oneline"

How to modify future rebase operations without aborting?

git rebase --edit-todo 

How to perform interactive rebase starting from the initial commit?

git rebase -i --root

What's the difference between squash and fixup in interactive rebase?

Squash preserves all commit messages from the squashed commits, while fixup discards the commit messages of the fixup commits.

How to change a branch name?

git branch -m <new-name>

Cherry pick commands to try:

git cherry-pick <commit-id> 
--edit # edit the commit message
--no-commit # just take the commit changes without commiting

git cherry-pick c362..e0b7 # (range of commits)

Stashing commands to try:

git stash apply # apply last stash without removing it
git stash -m "WIP in issue fixing .."
git stash pop stash@{1} # to pop a specific one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment