本文介绍 Git 的基础配置。
对于符号链接,Windows 需要额外设置才能获得更好的兼容性。
这里重点关注 Git 在 Windows 与 Unix-like 系统之间的兼容性。
git config --global user.name 'NAME'
git config --global user.email 'EMAIL@EXAMPLE.COM'
git config --global user.signingkey XXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXX:个人 GPG 私钥的 LONG 或 SHORT 格式。
git config --global gpg.program C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
git config --global commit.gpgsign true
git config --global tag.gpgsign true
git config --global core.filemode false
git config --global core.autocrlf true
git config --global core.ignorecase false
git config --global core.symlinks true
在 Windows 10 及以上版本中启用开发者模式。
安装 Git for Windows 时启用 symlinks。
组策略:
进入创建符号链接权限设置:
Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links
输入用户名,点击 “Check Names”,然后确认。
git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f"
git config --global filter.lfs.process "git-lfs filter-process --skip"
email = Username@example.com
signingkey = XXXXXXXXXXXXXXXX
program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe
smudge = git-lfs smudge --skip -- %f
process = git-lfs filter-process --skip
mklink [[/d] | [/h] | [/j]] <link> <target>
/d Creates a directory symbolic link. By default, this command creates a file symbolic link.
/h Creates a hard link instead of a symbolic link.
/j Creates a Directory Junction.
<link> Specifies the name of the symbolic link being created.
<target> Specifies the path (relative or absolute) that the new symbolic link refers to.
/? Displays help at the command prompt.
git push origin --delete <tagname>
git push origin <tagname>
git branch -d <branchname>
git push origin --delete <branchname>
[1]. https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work
[2]. https://github.com/git-for-windows/git/wiki/Symbolic-Links
[3]. https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink
[4]. 从一个git仓库提交代码到另一个仓库
[5]. GitLab-CI-CD-Push-to-Repository