git environment configuration
Configure username and email address
git config --global user.name "username"
git config --global user.email [email protected]
View all configurations
git config --list
View a specific configuration
git config user.name
View all configurations and files
git config --list --show-origin
git ignore file configuration
Files containing sensitive information such as database passwords cannot be submitted. Easy solution
with ignoring special files .gitignore
rules for ignoring files
- Ignore files automatically generated by the operating system, such as thumbnails
- Ignore the intermediate files, executable files, etc. generated by compilation, such as .class files
- Ignore configuration files that carry sensitive information, such as configuration files that store passwords
write ignore file
# “#”号开头的是注释行
# 忽略所有. 开头的文件
.*
# 不忽略.gitignore文件
!.gitignore
# 忽略所有以.class结尾的文件
*.class
Force commits for ignored files
Including App.class is ignored in the above settings, this file cannot be ignored
git add -f App.class
check ignore rules
You can view the line in the .gitignore file that ignores the specified file
git check-ignore -v App.class
git configure aliases
The following command configures the alias co for checkout, which can be used directly after switching branches: git co branch name
git config --global alias.co checkout