Getting started with git
Configuration
git config --global user.name "<username>"
git config --global user.email <email> # use private email set with git client
git config --global core.editor vim
Git can be congigured from system level to specific repository level.
--system option modify the file in /etc/gitconfig
--local option modify the file in .git/config
Generate SSH keypair
~/.ssh directoryssh-agentls -al ~/.ssh
ssh-keygen -t ed25519 -C "<email>" # comment is optionnaly used to distinguish the key later
ssh-keygen -p -f ~/.ssh/id_ed25519 # -p change or add the passphrase if needed while -f specify the private key file path
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub # copy the output into the git client
I didn't get why my current shell can interact with the ssh-agent now.
The process is running in the background while you capture its output...
And I evaluate its environment variables in the shell... makes sense.
When child processes, such as GUI applications, need to inherit the ssh-agent environment to work, exec ssh-agent <bash> can be used to replace the current shell for a new one under ssh-agent.
Set up remote
git init
git remote add origin <remote_url>
Already rebasing
Rebase bad commits
git stash -u
git rebase -i HEAD~N
git log --oneline -N
git push --force-with-lease origin main
git stash pop
Redo a bad rebase
reflog where to rewind the HEAD
HEAD before the mistakegit reflog
git stash -u
git reset --hard HEAD@{N}
git rebase -i HEAD~N
git log --oneline -N
git push --force-with-lease origin main
git stash pop