[git/github] 버전을 만들어보자

EUGENE·2023년 4월 25일
0

git/github 공부

목록 보기
2/2

📌 흐름을 이해하기

이제부터 이 폴더 안에서 버전관리를 시작할거야!

$ git init

이 폴더의 상태를 확인하고 싶다!

$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.txt

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

No commit yet 아직 커밋되지 않았다

Untracked files 못보던 새로운 파일이 생겼습니다!

이제 test.txt를 staging area로 올려보자!

$ git add test.txt 
										// 아무것도 안뜨면 잘 add 된거임
$ git status
On branch master

No commits yet

Changes to be committed: // 변화가 감지됐다!
  (use "git rm --cached <file>..." to unstage)
        new file:   test.txt

다시 내리는 것도 가능?

$ git rm --cached test.txt
rm 'test.txt'

$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        test.txt

올려야할 파일이 너무 많거나 전부 올리려면 어떡해요?

$ git add .     // 모두  staging area 로 옮겨라! 는 의미

Staging Area에서 Depository로 옮기기

$ git commit -m "commit message"
$ git commit -m "first commit"
[master (root-commit) 0c580a9] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt

커밋 메세지가 뭔가요?

📌 어떤 변경사항이 생겨서 버전을 생성했는지 알려주기 위해 적는 메시지

커밋한 내역을 확인하고 싶어요

$ git log
commit 0c580a93a7919d0c6ec3ab99a01153ac534d5537 (HEAD -> master)
Author: Eugene Kim <hash_ff0000@naver.com>
Date:   Wed Apr 26 01:39:24 2023 +0900

    first commit

만약 파일을 수정한다면?

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   test.txt

no changes added to commit (use "git add" and/or "git commit -a")

수정한 파일을 다시 Staging Area로 옮기는건?

$ git add test.txt

$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   test.txt

그걸 버전으로 만들려면?

$ git commit -m "add string to test"
[master 7f63648] add string to test
 1 file changed, 1 insertion(+), 1 deletion(-)

$ git log
commit 7f63648c15ef69c06a302883b098f9b384883d26 (HEAD -> master)
Author: Eugene Kim <hash_ff0000@naver.com>
Date:   Wed Apr 26 01:49:38 2023 +0900

    add string to test

commit 0c580a93a7919d0c6ec3ab99a01153ac534d5537
Author: Eugene Kim <hash_ff0000@naver.com>
Date:   Wed Apr 26 01:39:24 2023 +0900

    first commit

commit에 관하여

commit할때 -m을 붙이지 않으면 자동으로 vi가 실행되는데, 그곳에 commit message를 더욱 자세히 적을 수 있다!

여기서 드는 의문점

❓ `git commit` 명령어를 통해 버전을 만들면 내 컴퓨터 속 저장소에만 저장되는데

어떻게 다른 사람과 원격으로 협업을 할 수가 있는거죠?
효율적으로 백업했다고 말할 수 있나요?

⇒ 그래서 깃헙을 쓰는거다!

: 각자의 컴퓨터에만 존재하는 버전을 저장, 관리해주는 서비스

github에 코드를 업로드 한다 == github에 push한다.

📌 내 컴퓨터 : Local 저장소

github이 관리하는 컴퓨터 : 원격 저장소

Repository에 있는 모든 version이 모두 원격 저장소로 올라간다고 생각하면 됩니다

출처

https://www.inflearn.com/course/%EB%B9%A0%EB%A5%B4%EA%B2%8C-git/dashboard

profile
한 줄로 소개하기엔 여백이 좁아 적지 않겠습니다.

0개의 댓글