git: Selective upload by configuring .gitignore

What it is : Git is a free and open source distributed version control system designed to handle everything from small to large projects quickly and efficiently. It is widely used by many developers around the world and has powerful branch management, version control and other functions. A .gitignore file is a text file that tells Git which files or directories should not be added to the repository. In other words, any files or directories listed in the .gitignore file will be ignored by Git. This function is very useful, because in a project, we may have some files, such as compiled files, log files, local configuration files, etc., which we do not want to submit to the code repository.

History Raiders:

github: a coup to improve efficiency

git: clone specified branch

Git: win10 installation, command collection

Create a .gitignore file : In the project root directory, create a new file named .gitignore (note that the file name starts with a dot and does not have any extension). Then add to this file the patterns of the files or directories you want Git to ignore.

The basic syntax rules of .gitignore:

# 用于添加注释。以 # 开始的行将被 Git 忽略。
* 用于匹配任意数量的字符。比如, *.log 将匹配所有的 log 文件。
? 用于匹配单个字符。比如, ?.log 将匹配 a.log 但不匹配 aa.log。
[abc] 用于匹配任何列在方括号内的字符。比如, [abc].log 将匹配 a.log、b.log 和 c.log。
/ 用于忽略特定目录下的文件或子目录。比如, test/ 将忽略 test 目录下的所有文件。
! 用于否定之前的规则,即不忽略匹配到的文件或目录。比如, !important.log 将不忽略 important.log 文件。

case:

# 忽略所有 .log 文件
*.log

# 忽略 test 目录下的所有文件
/test/

# 但不忽略 test/important.log 文件
!/test/important.log

Summary : The .gitignore file is a powerful tool that helps us manage the files in the warehouse, allowing us to focus more on important codes rather than irrelevant temporary files or logs, which can significantly improve your work efficiency.

Guess you like

Origin blog.csdn.net/hzblucky1314/article/details/131035634