-
Notifications
You must be signed in to change notification settings - Fork 0
Git
Work in directories outside of cloned repo, in disctinct branches: git-worktree.
git worktree add c:/trees/AP-4321 -b bug/AP-4321_fix_xyz -> new branch named bug/AP-4321_fix_xyz
git worktree add <path> <branch> -> existing branch
git worktree add ../hotfix -> new branch named hotfix
git worktree list
c:/repos/win b8026860 [bug/AP-3571_catch_parse_exception]
c:/trees/AP-3549 b8026860 [bug/AP-3549_LogSender_destruction]
git worktree remove c:/trees/AP-4321
~/.gitconfig
[user]
name = Dave Cox
email = dcox@bgrove.com
# this SSH (built-in with newer Win10) uses Windows's ssh-agent service, whereas
# Sublime Merge's default SSH does not. 20201009
[core]
sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
-
ssh-agent service = “OpenSSH Authentication Agent”
-
may have to install OpenSSH for Windows:
https://medium.com/rkttu/set-up-ssh-key-and-git-integration-in-windows-10-native-way-c9b94952dd2c -
add key to ssh-agent so it may cache the password to unlock the key:
c:\Users\dcox> ssh-add .\.ssh\git-client-key-20201007 -
.ssh/config
Host bitbucket.org
User dave-cox
IdentityFile C:\Users\dcox\.ssh\git-client-key-20201007
ssh-agent -s emits script code to set environment variables that ssh and ssh-add need to connect to the agent. And then ssh-agent forks to run in the background, without using shell’s background jobs facility. So do this to install the environment variables into running shell:
eval $(ssh-agent -s)
The ssh-agent instance runs only as long as bash terminals are open. It should be possible to make a Windows Scheduled Task that runs on user logon to launch wsl.exe to run ssh-agent, perhaps via intermediate shell script. Need ssh-agent -D to avoid forking and terminating the foreground ssh-agent process. wsl.exe --user dave --exec ssh-agent -D seems to work.
https://www.daveeddy.com/2017/10/18/persistent-sshagent-on-bash-on-ubuntu-on-windows/
Then add ssh key (found in ~/.ssh) to the agent:
ssh-add ~/.ssh/git-client-key-20201007
This will prompt for the passphrase to unlock the ssh key, and cache the key for use by ssh connections to the remote repo.
-
add key to keychain, analogous to adding it to ssh-agent/pageant, so it may cache the password to unlock the key:
ssh-add -K ~/.ssh/git-client-key-20200827Note: this doesn’t seem to stick across reboots; I’m having to repeat it each time. -
.ssh/config
Host *
UseKeychain yes
- trust the git server (e.g. bitbucket.com) by adding its ssh key to client’s
known_hostsfile:
ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts
-
.ssh/config, specify the key to add
Host *
UseKeychain yes
Host bitbucket.org
HostName bitbucket.org
User dave-cox
IdentityFile ~/.ssh/git-client-key-20200827
git update-index --chmod=+x /path/to/file
(https://stackoverflow.com/q/13237611/6169408)
- at remote repo:
git push --delete <origin> <tag-name> - local:
git tag -d <tag-name>
Do this upon dev box setup, and early in CI jobs, so cloning/fetching/pushing doesn’t try to translate line endings. Assuming you’re doing cross-platform development and want to use plain CR on Windows as well as Unix.
git config --global core.autocrlf false