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-nameSee commit differences between branches. Display commits that Branch-A has but Branch-B doesn't
git lost Branch-A..Branch-Bcherry-pick
Will apply selected commit to current branch
git cherry-pick commit-hashMultiple commits:
git cherry-pick commit-hash1 commit-hash2 commit-hash3Using 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-hashreset
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~1Will remove both the lastest commit and the changes in it.
git reset --hard HEAD~1rebase
git rebase branch-nameIf you want to abort the rebase at any point:
git rebase --abortrebase interactive
Start an interactive rebase for the last 4 commits:
git checkout branch-name
git rebased -i HEAD~4Can be used to squash commits (squashing multiple commits into one).