
📌GIT checkout VS reset
⚡ checkout은 head를 바꾼다.
git checkout A : 작업 디렉토리는 A버전이된다.
시간여행을 하는 것


git checkout main : 헤드를 메인으로 바꾼다.
워킹디렉토리는 다시 B와 같아진다. 시간여행을 끝낸 것


⚡ reset은 head의 branch를 바꾼다.
git reset A : head가 가리키는 branch인 main을 A로 바꾼다.
B 버전을 삭제하는 것.


git reset B : main이 B를 다시 가리키게 한다.
B 버전을 삭제하는 것. B는 복원된 것.

이 상태에서 git checkout B 하면

이 상태에서 다시 git reset A 하면?
현재 head가 가리키는 branch는 없기 때문에 head가 직접 A를 가리킨다.

출처 : 생활코딩 쇼츠 @coohde
📌 .gitignore
Here is a .gitignore file in one of my Laravel based project -
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
/.idea
/.vscode
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.env
.phpunit.result.cache
# personal rules
/site-content
/temp-files
*.log
깃은 기본적으로 깃이 설정된 폴더 하위에 있는 모든 파일을 트래킹
우리가 외부 라이브러리 설치해서 사용할때도 모든 코드가 깃에 트래킹
특히 npm install 많이 사용하면 현재 디렉토리에서 package.json 파일을 읽고 그 안에 정의된 의존성들이 모듈 폴더에 자동으로 설치된다.

이 때 별도의 `.gitignore`를 설정하지 않고 git add 랑 commit을 하고 push를 하면 설치된 모든 라이브러리 설정 파일들이 깃허브에 같이 올라가게 된다. 이 dummy를 함께 트래킹하고 싶지 않을 때 쓰는 것이 `.gitignore`이다. 프로젝트 최상위 폴더에 .gitignore이라는 이름을 가진 파일을 만들어 주고, 트래킹하지 않는 폴더나 파일을 직접 써 넣으면 그것들은 깃에 의해서 관리되지 않는다. 그래서 해당 파일들은 스테이징 영역에 올라가지 않는다.
⚡ .gitignore 사용법
터미널에 아래 명령어 입력 후 실행하기
touch .gitignore
이 명령어가 실행되면 이름없는 빈 문서 하나가 레파지토리에 새로 생성된다.
여기에 트래킹 하지 않을 폴더나 파일을 추가 해 준다.
⚡.gitignore 파일 문법
* (Asterisk) is used as a wildcard match i.e - *.log
/ (Forward slash) is used to ignore pathnames relative to the .gitignore file i.e - /temp-files
# (Number sign or Hash) is used to add comments to a .gitignore file i.e - # My custom rules
`*`는 와일드카드로, 해당 패턴에 일치하는 모든 파일을 의미한다. 예를 들어, `*.log`는 `.log` 확장자를 가진 모든 파일을 무시한다.
`/` 슬래시는 `.gitignore` 파일이 위치한 경로를 기준으로 상대적인 경로를 지정한다.. 예를 들어, `/temp-files`는 루트 디렉토리 아래에 있는 temp-files 폴더를 무시한다.
`#` 샾은 주석을 추가하는 데 사용된다. 주석은 Git에 영향을 미치지 않는다.
⚡Node.js 에서 일반적으로 .gitignore 해 주는 파일들
- node_modules/ 폴더 (모든 종속성 파일)
- .log 확장자를 가진 모든 파일 (로그 파일)
- .env 파일 (환경 설정 파일)
- dist/ 폴더 (빌드된 결과물)
포스팅에 참고한 블로그
https://coderomeos.org/gitignore-file-and-its-usage
Understanding .gitignore in Git
A .gitignore file in a repository tells to Git what file or directory to be ignored in the repository. To ignore any files or directory we create rules in .gitignore file residing in the root of the repository.
coderomeos.org
https://codingbash.com/tutorial/how-to-use-gitignore-file-in-git
Git Ignore
In this article, we will learn how to use .gitignore file to ignore the untracked files intentionally.
codingbash.com
'Git&GitHUB' 카테고리의 다른 글
[깃/깃허브] 소스트리 사용해보기 (96) | 2024.12.10 |
---|---|
[깃/깃허브] VSCode Git 10k 없애기 ( the git repository at XX has too many changes ) (7) | 2024.12.06 |
[깃/깃허브] diff, difftool, gitGraph(VSCode 익스텐션) 사용법 (62) | 2024.11.30 |
[깃/깃허브] 깃허브 좋은 기능 (웹에서 VSCode 열고 편집 / 커밋하기) (62) | 2024.11.30 |
[깃/깃허브] 맥OS에서 버전관리도구 깃(Git) 설치 / 셋팅하기 (10) | 2024.11.30 |

📌GIT checkout VS reset
⚡ checkout은 head를 바꾼다.
git checkout A : 작업 디렉토리는 A버전이된다.
시간여행을 하는 것


git checkout main : 헤드를 메인으로 바꾼다.
워킹디렉토리는 다시 B와 같아진다. 시간여행을 끝낸 것


⚡ reset은 head의 branch를 바꾼다.
git reset A : head가 가리키는 branch인 main을 A로 바꾼다.
B 버전을 삭제하는 것.


git reset B : main이 B를 다시 가리키게 한다.
B 버전을 삭제하는 것. B는 복원된 것.

이 상태에서 git checkout B 하면

이 상태에서 다시 git reset A 하면?
현재 head가 가리키는 branch는 없기 때문에 head가 직접 A를 가리킨다.

출처 : 생활코딩 쇼츠 @coohde
📌 .gitignore
Here is a .gitignore file in one of my Laravel based project - /node_modules /public/hot /public/storage /storage/*.key /vendor /.idea /.vscode /.vagrant Homestead.json Homestead.yaml npm-debug.log yarn-error.log .env .phpunit.result.cache # personal rules /site-content /temp-files *.log
깃은 기본적으로 깃이 설정된 폴더 하위에 있는 모든 파일을 트래킹
우리가 외부 라이브러리 설치해서 사용할때도 모든 코드가 깃에 트래킹
특히 npm install 많이 사용하면 현재 디렉토리에서 package.json 파일을 읽고 그 안에 정의된 의존성들이 모듈 폴더에 자동으로 설치된다.

이 때 별도의 .gitignore
를 설정하지 않고 git add 랑 commit을 하고 push를 하면 설치된 모든 라이브러리 설정 파일들이 깃허브에 같이 올라가게 된다. 이 dummy를 함께 트래킹하고 싶지 않을 때 쓰는 것이 .gitignore
이다. 프로젝트 최상위 폴더에 .gitignore이라는 이름을 가진 파일을 만들어 주고, 트래킹하지 않는 폴더나 파일을 직접 써 넣으면 그것들은 깃에 의해서 관리되지 않는다. 그래서 해당 파일들은 스테이징 영역에 올라가지 않는다.
⚡ .gitignore 사용법
터미널에 아래 명령어 입력 후 실행하기
touch .gitignore
이 명령어가 실행되면 이름없는 빈 문서 하나가 레파지토리에 새로 생성된다.
여기에 트래킹 하지 않을 폴더나 파일을 추가 해 준다.
⚡.gitignore 파일 문법
* (Asterisk) is used as a wildcard match i.e - *.log
/ (Forward slash) is used to ignore pathnames relative to the .gitignore file i.e - /temp-files
# (Number sign or Hash) is used to add comments to a .gitignore file i.e - # My custom rules
*
는 와일드카드로, 해당 패턴에 일치하는 모든 파일을 의미한다. 예를 들어, *.log
는 .log
확장자를 가진 모든 파일을 무시한다.
/
슬래시는 .gitignore
파일이 위치한 경로를 기준으로 상대적인 경로를 지정한다.. 예를 들어, /temp-files
는 루트 디렉토리 아래에 있는 temp-files 폴더를 무시한다.
#
샾은 주석을 추가하는 데 사용된다. 주석은 Git에 영향을 미치지 않는다.
⚡Node.js 에서 일반적으로 .gitignore 해 주는 파일들
- node_modules/ 폴더 (모든 종속성 파일)
- .log 확장자를 가진 모든 파일 (로그 파일)
- .env 파일 (환경 설정 파일)
- dist/ 폴더 (빌드된 결과물)
포스팅에 참고한 블로그
https://coderomeos.org/gitignore-file-and-its-usage
Understanding .gitignore in Git
A .gitignore file in a repository tells to Git what file or directory to be ignored in the repository. To ignore any files or directory we create rules in .gitignore file residing in the root of the repository.
coderomeos.org
https://codingbash.com/tutorial/how-to-use-gitignore-file-in-git
Git Ignore
In this article, we will learn how to use .gitignore file to ignore the untracked files intentionally.
codingbash.com
'Git&GitHUB' 카테고리의 다른 글
[깃/깃허브] 소스트리 사용해보기 (96) | 2024.12.10 |
---|---|
[깃/깃허브] VSCode Git 10k 없애기 ( the git repository at XX has too many changes ) (7) | 2024.12.06 |
[깃/깃허브] diff, difftool, gitGraph(VSCode 익스텐션) 사용법 (62) | 2024.11.30 |
[깃/깃허브] 깃허브 좋은 기능 (웹에서 VSCode 열고 편집 / 커밋하기) (62) | 2024.11.30 |
[깃/깃허브] 맥OS에서 버전관리도구 깃(Git) 설치 / 셋팅하기 (10) | 2024.11.30 |