Forgit me nots

August 11, 2019 • 1 min read

Squashing commits on Windows

I know there’s a better way to do this (using rebase) but I like this way since it gives me more control.

git merge-base master yourBranch

# note commit hash

git reset --soft # enter commit hash

# all changes can now be committed again

It’s easier on *nix using the following oneliner:

git reset $(git merge-base master $(git rev-parse --abbrev-ref HEAD))

Rebasing without pulling master

Rebase using the remote master to make sure you’re really up to date. Useful when updating merge requests (on GitLab).

git pull --rebase origin master

Useful aliases

ac=!git add . && git commit
ls=log --pretty=format:%C(green)%h\ %C(yellow)[%ad]%Cred%d\ %Creset%s%Cblue\ [%cn] --decorate --date=relative
undo=reset --soft HEAD^

Create merge request

git pull-request

Got any questions, found a mistake? You can find me on Twitter as @vnglst. You can also discuss the article on TwitterSuggest changes on Gitlab

Koen van Gilst

Koen van Gilst

Personal blog by Koen van Gilst. JavaScript developer, M.A. in Philosophy, former translator.