git checkout -b <local branch> origin/<remote branch>
... creates a local branch "local branch" and sets it to track origin's branch "remote branch"
git commit --amend --no-edit
... ammends commit without changing the commit message
git reset --hard HEAD
... returns to the pre-merge state while merging
git checkout mybranch && git reset --hard origin/mybranch
... resets a local branch to the state of a remote branch
git restore --staged <file>
... unstages file
git reset --hard ORIG_HEAD
... if you've already committed the merge that you want to throw away
git rm --cached settings_local.py
... untrack the file without removing it
git push origin +dd61ab32^:master
... update the remote master-branch moving the HEAD to a given commit
git push origin :serverfix
... delete the remote branch 'serverfix'
git log --committer=sgs
... only show commits matching commiter 'sgs'
git show --pretty="" --name-only <commit-id>
... shows only the modified files for the given commit-id
git tag -d <thetag>
git push origin :refs/tags/<thetag>
... removes
git show-ref -d --tags
... shows annotated tags with ^{}, while lightweight without
git rebase -i origin/master
... rebases interactively
git restore :/
... restores all changes
git rebase -i HEAD~3
... selects the last 3 commits interactively, ordering them with the last at the bottom of the interactive file
We then mark the line at the top (chronologically the first commit) with 'pick' and the rest of the lines with 'squash' or 's'.
Finally we are also adding a proper commit message.
Using 'fixup' or 'f' instead of 'squash' will produce the same result, except it will not prompt for a new commit message and will use the commit message of the first commit.
git merge --squash <branch-name>
... takes all the commits from the branch, squashes them, and stages all changes in the current branch
git config user.signingKey A6645797661E2F473DD3FF06BCE70555C3BB08F7
git config commit.gpgSign true
... sets the automatic signing of commits. git config --global sets it globally
2026-06-17 22:02:47
minicms - © 2020-2026 Simeon Simeonov