Some common and useful Git commands.
git log
git reflog
By SHA:
git diff --name-only af43c41d..HEAD
git diff af43c41d..master
By branch:
git diff --name-only origin/deploy..master
git diff origin/deploy..master
Review, alter, remove, amend last 3
commits:
git rebase -i HEAD~3
i
to enter interactive mode
.pick
, drop
, etc.esc
button to exit interactive mode
.wq
to save and close the file (Git will proceed through the stipulated changes) or type q!
to close the file abandoning all changes.git push -f
to override previous changes - do not use this on master/main
only ever within a development branch.Correct the last commit message:
git commit --amend -m "Your new message"
git clean -f -d
git reset --hard HEAD
git rebase --abort
git clean -f -d
git reset --hard HEAD
If a branch contains a dir in the root with the same name as a branch, Git will now complain.
Use the following instead:
git fetch origin deploy
(if freshly cloned)git switch -f deploy