Get the App
SLTechnology News&Howtos  ›  Servers  › 

Sharing of git file management experience

Shulou Source: shulou.com Published: 2022-06-02 03:43:46 10月03日 Update

Untraked file untracked files, usually newly created files

Traked file is usually the file after indexing

Ignored ignored files, this type of file is usually in a file list. The file that maintains this list is named .gitignore in the root directory of the version library.

Initialize the version library to ensure the newly created state

Huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $ls hello huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $ls-a. /.. / .git / hello huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $rm-rf. Git / hello huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo $git init Initialized empty Git repository in C:/Users/huawei/Desktop/git-repo/.git/

Create files to view file types and find files that are not tracked by untraked file

Huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $echo "hello world" > hello huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $git status On branch master No commits yet Untracked files: (use "git add..." To include in what will be committed) hello nothing added to commit but untracked files present (use "git add" to track)

The files being tracked are usually indexed and can be viewed through git ls-files-s. For ignored files, please see the following demo and write the file name to the .gitignore file.

Huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $git status On branch master nothing to commit, working tree clean huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $echo "a" > a huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $git status On branch master Untracked files: (use "git add..." To include in what will be committed) a nothing added to commit but untracked files present (use "git add" to track) huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $echo a > > .gitignore huawei@DESKTOP-JTC012C MINGW64 ~ / Desktop/git-repo (master) $git status On branch master Untracked files: (use "git add..." To include in what will be committed) .gitignore nothing added to commit but untracked files present (use "git add" to track)

.gitignore file syntax

The lines at the beginning of # are used for comments

Blank lines will be commented

The end of the directory name is marked with a backslash (/)

Contains shell wildcards, such as *. Example debug/32bit/*.o

The starting exclamation point is used to take the anti-pattern.

Tags: File trace comment version type index can pass name beginning exclamation mark file name slash end tag root directory pattern status directory name directory name blank line Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info NVidia Redmi OPPO Reno Xiaomi