Home
Tags:

git - continued

log

To view the logs for a different branch (to the one you are already on) in Git, you can use the git log command followed by the branch name.

git log branch-name

See commit differences between branches. Display commits that Branch-A has but Branch-B doesn't

git lost Branch-A..Branch-B

cherry-pick

Will apply selected commit to current branch

git cherry-pick commit-hash

Multiple commits:

git cherry-pick commit-hash1 commit-hash2 commit-hash3

Using the --no-commit option with git cherry-pick allows you to apply changes from a specific commit to your working directory and staging area without creating a new commit. This gives you the flexibility ot review and modify the changes before committing them.

git cherry-pick --no-commit commit-hash

reset

Will remove the lastest commit. The changes are kept in the working directory and staging area, so that they are ready to be committed again if needed.

git reset --soft HEAD~1

Will remove both the lastest commit and the changes in it.

git reset --hard HEAD~1

rebase

git rebase branch-name

If you want to abort the rebase at any point:

git rebase --abort

rebase interactive

Start an interactive rebase for the last 4 commits:

git checkout branch-name
git rebased -i HEAD~4

Can be used to squash commits (squashing multiple commits into one).