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
.diff
by appending.diff
to 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 -n
Commit:
git clean -d -f
https://linuxize.com/post/how-to-remove-untracked-files-in-git/