Further git tips
Additional git tips¶
If you are working locally, and realise you have accidentally been making changes on main instead of another branch:
$ git stash
$ git checkout -b correct-branch
$ git stash pop
Messed up your main branch?
$ git checkout main
$ git fetch upstream
$ git reset --hard HEAD
$ git push
Correct your last commit
$ git commit --amend -s -m "New commit message"
View recent changes
$ git log
View recent changes in a prettier way:
$ git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
Take a fix you have pushed to a different branch (perhaps a top-level pom change, or something else you need) and apply it to your current branch:
$ git cherry-pick <commit-id>
Raise an issue or comment below