git
reviewing a merge commit locally
bashgit config --add remote.origin.fetch +refs/pull/*/merge:refs/remotes/origin/pr/* git fetch origin git checkout pr/1234
backup github repos
Backup personal github repos
shelldocker run -it -v ${PWD}:/out python:3 bash pip install git+https://github.com/clockfort/GitHub-Backup chmod +x /usr/local/lib/python3.11/site-packages/github_backup/github_backup.py /usr/local/lib/python3.11/site-packages/github_backup/github_backup.py staff0rd /out/backup -p YOUR_PAT -t http
aliases
shellgit config --global alias.co checkout git config --global alias.branches "branch --sort=-committerdate" git config --global alias.yo 'checkout -' git config --global alias.run "!gh run watch"
integrate beyond compare in wsl
Inside ~/.gitconfig:
ini[diff] tool = bcomp [difftool] prompt = false [difftool "bcomp"] path = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe" cmd = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe" "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" [merge] tool = bcomp [mergetool] prompt = false [mergetool "bcomp"] path = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe" cmd = "/mnt/c/Program\\ Files/Beyond\\ Compare\\ 4/BCompare.exe" "$(wslpath -aw $LOCAL)" "$(wslpath -aw $REMOTE)" "$(wslpath -aw $BASE)" "$(wslpath -aw $MERGED)"
integrate beyond compare
bash# diff git config --global diff.tool bc3 # merge git config --global merge.tool bc3 git config --global mergetool.bc3.trustExitCode true
configure windows ssh
- Set service
OpenSSH Authentication AgenttoAutomaticandStartit. - In Powershell,
ssh-add - In environment variables, add
GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe
find an edited file in any commit or stash
made changes a to a file but don’t know the branch or stash?
find it across all branches:
bashgit reflog -- {path-to-file}
find it in the stash:
bashgit reflog stash -- {path-to-file}
set upstream branch automatically
bashgit config --global push.default current
Now you can git push a new branch without needing to git push -u some-branch
set user and email
bashgit config --global user.name "Stafford Williams" git config --global user.email "stafford.williams@gmail.com" git config --global core.editor "vim"
adding keys
bashsudo apt-get install keychain ssh-keygen -t ed25519 -C "stafford.williams@gmail.com"
linux:
bashecho "eval \`keychain --clear --eval id_ed25519\`" >> ~/.profile cat ~/.ssh/id_ed25519.pub
macOS: see docs