Published 2月 27, 2024 by with 0 comment

Git Lab 04 - Ignoring Files


The .gitignore file: A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected


Lab 4.1: Create a .gitignore 

gitignore - Specifies intentionally untracked files to ignore

Example Code:
$ git status
$ touch .gitignore
$ dir -al
$ git status
$ git add .gitignore
$ git status
$ git commit -m "add .gitignore file"
$ git status


Lab 4.2: Tracking New Files

Create a file "lab4-2.txt".
Tells Git to ignore any files ending in “txt”.

Example Code:
$ git status
$ echo "lab4-2" > lab4-2.txt 
$ dir -al
$ cat lab4-2.txt
$ git status
$ echo "*.txt" > .gitignore
$ git status
$ git add .gitignore
$ git status
$ git commit -m "add *txt for .gitignore"
$ git status

Reference:
1. Git - Commands Reference

2. Git Basics - Recording Changes to the Repository

3. Git 教程


最初發表 / 最後更新: 2024-02-27 / 2024-02-27

0 comments:

張貼留言