Git for Windows - KineticTheory/Linux-HPC-Env GitHub Wiki

General Settings

Extra customization for git for Windows.

  • Basic global configuration (~/.gitconfig or c:\Users\<moniker>\.gitconfig)
[user]
	name = Kelly (KT) Thompson
	email = [email protected]
[color]
	ui = auto
[core]
        autocrlf = input
        editor = \"C:\\Program Files\\Notepad++\\notepad++.exe\" -multiInst -notabbar -nosession -noPlugin
[diff]
        tool = meld
[difftool]
        prompt = false
[difftool "meld"]
        cmd = meld "$LOCAL" "$REMOTE"
[merge]
        tool = winmerge
[mergetool]
	prompt = false
[mergetool "meld"]
        cmd = meld "$LOCAL" "$MERGED" "$REMOTE" --outpupt "$MERGED"
[mergetool "winmerge"]
	cmd = \"C:\\Program Files (x86)\\WinMerge\\WinMergeU.exe\" -e -u -dl \"Base\" -dr \"Mine\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
[fetch]
	prune = true
[pull]
	rebase = true
[ssh]
	variant = putty
[credential]
	helper = manager
[http]
	proxy = http://proxyout.lanl.gov:8080
  • Also, see the official documentation: Git Configuration
  • Allow git to work with Meld for merges and diffs
  • Since many of my projects use clang-format as a pre-commit hook for git, I needed to ensure that the application could be found from the Bash command shell.
    • Append %HOMEDRIVE%\%HOMEPATH%\.bash_profile (e.g.: c:\Users\username\.bash_profile) export PATH=$PATH:/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2019/Community/VC/Tools/Llvm/bin"
  • Also change the default behavior of gitk by modifying %HOMEDRIVE%\%HOMEPATH%\.bash_profile
    • alias gitk='gitk --all'
  • Follow these instructions to allow git use Pageant keys: https://github.com/git-for-windows/git/wiki/OpenSSH-Integration-with-Pageant
    • Basically add this to your .bash_profile in the the 'Git Bash Shell'
# ssh-pageant allows use of the PuTTY authentication agent (Pageant)
SSH_PAGEANT="$(command -v ssh-pageant)"
if [ -x "$SSH_PAGEANT" ]; then
   eval $("$SSH_PAGEANT" -qra "${SSH_AUTH_SOCK:-${TEMP:-/tmp}/.ssh-pageant-$USERNAME}")
fi
unset SSH_PAGEANT

Settings for using Emacs with Git

  • Use Emacs Ediff for mergetool by appending ~/.gitconfig:
[mergetool.ediff]
    cmd = emacs --eval \"\
(progn\
  (defun ediff-write-merge-buffer ()\
    (let ((file ediff-merge-store-file))\
      (set-buffer ediff-buffer-C)\
      (write-region (point-min) (point-max) file)\
      (message \\\"Merge buffer saved in: %s\\\" file)\
      (set-buffer-modified-p nil)\
      (sit-for 1)))\
  (setq ediff-quit-hook 'kill-emacs\
        ediff-quit-merge-hook 'ediff-write-merge-buffer)\
  (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\"\
                                   \\\"$BASE\\\" nil \\\"$MERGED\\\"))\"

Next: Windows 10 Tweaks

⚠️ **GitHub.com Fallback** ⚠️