Git Configuration
0. Introduction
Section titled “0. Introduction”In this article, we introduces git configuration for basic use.
Remarkablely, configurations for symbolic links are supported on Windows with extra settings.
The purpose we have to point out, is the git compatibility on both Windows and Unix like system.
1. Git Initialization
Section titled “1. Git Initialization”- Config User Name
git config --global user.name 'NAME'- Config User Email
git config --global user.email 'EMAIL@EXAMPLE.COM'2. Config Git with GPG
Section titled “2. Config Git with GPG”- Config signingkey
git config --global user.signingkey XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: Personal gpg private key in LONG or SHORT format
- Config GPG
git config --global gpg.program C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe- Config Commit and Tag
git config --global commit.gpgsign truegit config --global tag.gpgsign true3. Config Git on Windows for compatibility with Unix like system
Section titled “3. Config Git on Windows for compatibility with Unix like system”- Config filemode authority
git config --global core.filemode false- Config CRLF and LF auto change
git config --global core.autocrlf true- Config case-sensitive
git config --global core.ignorecase false- Config symlinks
git config --global core.symlinks true3.1 Additional settings on Windows
Section titled “3.1 Additional settings on Windows”- Enable Develop Mode on Windows10 and later
- Enable
symlinkson installing git on Windows - Group Policy:
- Navigate to create user permission to create symbolic links:
- Computer Configuration → Windows Settings → Security Settings → Local Policies → User Rights Assignment → Create symbolic links
- type the user name and click “Check Names” then OK.
4. Config Git ignore LFS by default
Section titled “4. Config Git ignore LFS by default”git config --global filter.lfs.smudge "git-lfs smudge --skip -- %f"git config --global filter.lfs.process "git-lfs filter-process --skip"5. .gitconfig Looks Like
Section titled “5. .gitconfig Looks Like”[core] symlinks = true autocrlf = true filemode = false ignorecase = false[user] name = User Name email = Username@example.com signingkey = XXXXXXXXXXXXXXXX[commit] gpgsign = true[tag] gpgsign = true[gpg] program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe[filter "lfs"] smudge = git-lfs smudge --skip -- %f process = git-lfs filter-process --skip6. Add symbolic links on Windows
Section titled “6. Add symbolic links on Windows”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.
7. Add Tag
Section titled “7. Add Tag”git tag XXXX8. Delete Tag
Section titled “8. Delete Tag”git tag -d <tagname>git push origin --delete <tagname>9. Commit Tag
Section titled “9. Commit Tag”git push origin <tagname>10. Delete Git Branch
Section titled “10. Delete Git Branch”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仓库提交代码到另一个仓库