잘 정리해보자

Node.js 프로젝트에서 Git 세팅 - 1 본문

javascript/Node.js

Node.js 프로젝트에서 Git 세팅 - 1

토마토오이 2021. 6. 15. 00:08

Github에 로그인 되어 있고, Git이 설치된 상태에서 진행

Logon failed, use ctrl+c to cancel basic credential prompt.

1. 터미널에서 base-nodejs 프로젝트에 git 세팅

 

git init
C:\base-nodejs>git init
Initialized empty Git repository in C:/base-nodejs/.git/

 

프로젝트에 비어있는 git 저장소를 생성했다는 문구가 뜬다.

 

git remote add origin https://github.com/[저장소]/[프로젝트경로]

Git저장소 url로 연결한다.

 

 

 

 

 

2. Git의 현재 상태를 확인

 

C:\base-nodejs>git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        node_modules/
        package-lock.json
        package.json

nothing added to commit but untracked files present (use "git add" to track)

git status 명령어를 통해 확인해보니, Git 저장소에 커밋될 목록들이 출력된다. 

 

커밋 목록에 node_modules 파일이 포함되어 있는데, 파일 크기가 적지 않아서 제외하고 올리는 편이 좋다.

 

 

 

 

 

 

 

3. 커밋을 제외할 대상을 저장하는 파일 생성

프로젝트에서 .gitignore 파일을 생성하고 커밋에서 제외(무시)될 대상파일명을 입력한다.

 

 

node_modules 파일을 입력 저장 후, git status로 터미널에서 커밋 목록 확인

 

C:\base-nodejs>git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        package-lock.json
        package.json

nothing added to commit but untracked files present (use "git add" to track)

> node_modules 가 대상에서 제외되고 .gitignore 파일로 대체되었다.

> .gitignore 파일을 커밋해서 제외대는 대상들을 이 파일로 관리한다.

 

 

 

 

 

'javascript > Node.js' 카테고리의 다른 글

Node.js 프로젝트에서 Git 세팅 - 2  (0) 2021.06.15
Node.js 시작  (0) 2021.06.14
Comments