Git tricks
Table of Contents
Collection of useful git commands etc.
Revert a pull/merge etc.-up-
- get a list of recent commits with
git log --oneline - select the hash (first word on each line) of the one you want to revert
git revert -m 1 <selected_hash>
Locally merge a pull request-up-
See this stackexchange Q&A.
After cloning the repo, choose one of these options:
- download the PR as a
.diffby appending.diffto the URL, e.g.:
github.com/user/repo/pull/123.diff
for PR 123, then patch manually. - issue
git pull origin pull/123/head.
Remove untracked files-up-
Dry run:
git clean -d -nCommit:
git clean -d -fhttps://linuxize.com/post/how-to-remove-untracked-files-in-git/
