All the commands, unordered.
Configure Git
REF: https://git-scm.com/book/uz/v2/Git-Tools-Signing-Your-Work
Add Identity
git config --global user.name "John Doe"
git config --global user.email "johndoe@example.com"
git config --global core.autocrlf input
git config --global core.safecrlf true
git config --global core.editor "nvim"
Avoid to convert endline ^M in some files
git config core.autocrlf false
Works with GPG
Adding your GPG key, found your key with: gpg -k | grep -i "\[s\]"
git config --global user.signingkey <ID KEY> # ID Key for Sign
Sign a commit
git commit -a -S -m 'signed commit' # -S for crypt commit
Look all the diff make today
git diff "@{yesterday}"
Restore a deleted branch
git reflog --no-abbrev
fd3...
git checkout -b release-0.4.0 fd3
Create a branch on a commit
git branch NEW_BRANCH_NAME COMMIT_ID
Closing Issue on Github
In a commit message, add any of: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved
The pull request must be on the default branch.
git commit -a -S -m "resolve #1, closes #2, closes #3; YOUR COMMIT MESSAGE"
Delete a branch on github
git branch -d devel
git push origin --delete devel
Clean a old Git main or master branch (safe way)
git clone https://github.com/szorfein/dotfiles && cd dotfiles
git checkout --orphan newBranch
git add -A
git commit
git branch -D master
git branch -m master
git push -f origin master
git gc --aggressive --prune=all
ref: https://gist.github.com/stephenhardy/5470814
Merge a pull request from another repository
git checkout -b marespiaut-patch-1 master
git pull https://github.com/marespiaut/szorfein.github.io.git patch-1 #
use the branch patch-1
git checkout master
git merge --no-ff marespiaut-patch-1
git branch -d marespiaut-patch-1
git push origin master
Merge a pull request from Copilot
git merge --no-ff origin/build/go-release
git push origin -d build/go-release
Delete your previous commit
Do this before pushing to a remote Git repository
git reset --soft HEAD~1