본문 바로가기

TIL/Git & Github

[TIL][Git][CLI] GIT으로 뭘할건데? - 1. 저장소 만들기(Make a Repository)

이전의 포스팅에 이어

 

git에 자신이 만든 파일(txt /html/ css / python ....etc)을 저장소에 저장하고 꺼내와서 수정하고 다시 올리고 이런 과정을 반복해서

하나의 완성도 높은 파일 혹은 프로젝트를 만드는 것이 목표이다.

 

나는 예를 간단한 텍스트 파일을 사용하겠다.

 

다운을 받았다면 본격적으로 시작하기 앞서 사용자 등록을 한다.

git config user.name "myname"
git config user.email "myemail@public"

간단한 사용자 등록을 마쳤다면 본격적으로 시작해보자 

 

1. 저장소 만들기

우선 자신의 로컬에 저장소를 만들어야 한다. 저장소는 보통 폴더안에 만드는데 파일을 관리해준다.

mkdir mypractice
cd mypractice

위처럼 mypractice라는 새로운 폴더를 만들고 그 폴더로 이동했다.

git status
fatal: not a git repository (or any of the parent directories): .git

현재 이 폴더(디렉토리)의 git의 상태를 검색해보니 저장소가 없다고 뜬다.

저장소를 처음 만들자 git init 을 입력한다.

git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /Users/로컬사용자/mypractice/.git/

자세한 설명과 함께 mypractice 폴더안에 git repos(저장소)가 생겼다.

내 저장소에 기본값으로 생기는 master(이름은 위와같이 변경 가능) 브랜치와 함께 저장소가 생겼다.

앞으로 이 브렌치에서 수정된 파일을 올리거나 새로운 브렌치를 만들수 있다.

 

git status
On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

master라는 브렌치에 있는 상태고 어떤 커밋도 없고 커밋할 것도 없다. (파일을 만들거나 복사해서 git add을 사용해라)

라는 메세지가 뜬다.

 

이제부터 파일을 만들고 수정하는 것에 대해 다음 게시글에 올리겠다.