Git .gitignore File ์ ์ฉํ๊ธฐ
.gitignore์ด๋?
Project์ ์ํ์ง ์๋ Backup File์ด๋ Log File , ํน์ ์ปดํ์ผ ๋ ํ์ผ๋ค์ Git์์ ์ ์ธ์ํฌ์ ์๋ ์ค์ File์ด๋ค.
1. .gitignore ํ์ผ ๋ง๋ค๊ธฐ
-
ํญ์ ์ต์์ Directory์ ์กด์ฌํด์ผํ๋ค.
-
Ex) ์์
- ๋ฌธ๋ฒ
# : comments
# no .a files
*.a
# but do track lib.a, even though you're ignoring .a files above
!lib.a
# only ignore the TODO file in the current directory, not subdir/TODO
/TODO
# ignore all files in the build/ directory
build/
# ignore doc/notes.txt, but not doc/server/arch.txt
doc/*.txt
# ignore all .pdf files in the doc/ directory
doc/**/*.pdf
2. ์ ์ฉํ๊ธฐ
- ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ด๋ ต์ง ์๋ค. .gitignore File์ ๊ฐ์ด Pushํ๋ฉด ๋๋ค.
- ๊ธฐ์กด์ ์๋ Project์ .gitignore File์ด ์ ์ฉ์ด ์๋๋ ๊ฒฝ์ฐ์๋ git Repository์์ ์ ์ฉํด๋ณด๊ณ ๋ค์ Pushํด๋ณด๊ธฐ ๋ฐ๋๋ค.
git rm -r --cached .
git add .
git commit -m "Apply .gitignore"
3. ํ์ธํด๋ณด๊ธฐ
- Local์์๋ ignoreFile์ด ์ฌ๋ผ์ง์ง ์์์ง๋ง Remote์ Push๊ฐ ๋ ๋์๋ ์ ์ฉ๋์ด ์ฌ๋ผ๊ฐ ๋ชจ์ต์ ๋ณผ ์ ์๋ค.