본문 바로가기
기타/git

[git/형상관리] git 최초 설정 및 프로젝트 생성 + .gitignore 추가

by drCode 2022. 8. 19.
728x90
반응형

git 최초 설정

(1) 본인이 원하는 위치에 폴더를 만든다.

 

C:\DEV\git-practice

 

 

(2) git 전반적으로 사용하게될 이름, 이메일을 지정한다.

git config --global user.name "홍길동"

git config --global user.email "hong_gildong@naver.com"

 

아래의 명령어로 제대로 입력되었는지 확인할 수 있다.

git config --global user.name

git config --global user.email

 

(3) 기본 브랜치를 마스터(master)에서 main 으로 변경한다.

git config --global init.defaultBranch main

 

git 프로젝트 생성

(1) 프로젝트를 VS Code를 이용하여 생성한다. 
     쉘은 bash로, C:\DEV\git-practice 디렉토리에 들어가서 git init을 입력

 

git init

 

(2) 해당 디렉토리에 아래의 파일들을 생성한다. 내용 입력 후 꼭 저장한다.

 

tigers.yaml

team: Tigers

manager: John

members:
- Linda
- William
- David

 

lions.yaml

team: Lions

manager: Mary

members:
- Thomas
- Karen
- Margaret

 

(3) git status로 확인한다.

git status

2개의 파일(lions.yaml, tigers.yaml)이 추가된 것을 확인할 수 있다.

 

 

※ SourceTree 를 사용하면 GUI 환경에서 git 프로젝트의 현황을 잘 볼 수 있다.

 

https://www.sourcetreeapp.com/

 

Sourcetree | Free Git GUI for Mac and Windows

A Git GUI that offers a visual representation of your repositories. Sourcetree is a free Git client for Windows and Mac.

www.sourcetreeapp.com

 

SourceTree

 

실행시킨 후 열면 위처럼 나오는데

 

C:\DEV\git-practice << 이 경로를 열면 

 

 

폴더 선택을 하면 

이렇게 나오게 된다.

 

.gitigonre 추가하기

.gitignore란? 

프로젝트에서 원치 않는 파일 혹은 디렉터리를 입력하면 해당 파일과 디렉터리의 모든 하위 파일들 혹은 디렉토리까지 git 프로젝트에서 제외시키는 기능

 

아래의 링크에서 .gitignore의 정보를 더 확인할 수 있다.

https://git-scm.com/docs/gitignore

 

Git - gitignore Documentation

The optional configuration variable core.excludesFile indicates a path to a file containing patterns of file names to exclude, similar to $GIT_DIR/info/exclude. Patterns in the exclude file are used in addition to those in $GIT_DIR/info/exclude.

git-scm.com

 

(1) secrets.yaml 추가

 

secrets.yaml

id: admin
pw: 1234abcd

 

위의 정보는 외부로 보여지면 안되는 파일이기 때문에 이 정보는 git에 포함시키지 않아야 한다.

 

(2) .gitignore 작성

 

.gitignore

secrets.yaml

# 주석은 '#'을 맨 앞에 붙여서 사용한다

 

.gitignore에 추가하면 해당 파일이 'U' 표시가 없다

 

git status로 확인해봐도 secrets.yaml은 없다

 

728x90
반응형

'기타 > git' 카테고리의 다른 글

[Git/형상관리] Git 설치  (0) 2021.08.26

댓글