본문 바로가기
개발자모드/혼자공부하는파이썬

[파이썬/장고#28] 깃으로 버전 관리하기 (Git 설치, Git 환경설정, Git명령어)

by 요니L 2022. 10. 11.

 

 

 

코드를 작성하다 보면 수정과 삭제를 많이 하게 된다. 가끔은 예전에 삭제한 코드도 되살려야 할 때도 있고, 수정한 코드를 다시 확인해야 할 때도 있다. 그러면 누가 어떤 부분을 왜 수정했는지 알아야 한다. 이런 경우 "버전 관리 시스템"을 도입하면 간단히 해결할 수 있다. 이 장에서는 버전 관리 시스템 중에서도 유명한 깃(Git)을 설치하고 사용해 보자.

 

 


깃(Git) 설치하기 

 

깃 공식 홈페이지에서 깃 설치 파일을 내려받아 설치하자. 설치 파일을 실행한 다음에는 계속 [Next]를 눌러 기본 옵션으로 설치하면 된다. 

 

깃 공식 홈페이지 : https://git-scm.com/

 

Git

 

git-scm.com

 

☞ 깃 설치하기 참고 

 

 

[깃(Git) 뽀개기①] 깃허브(GitHub) 저장소 생성 및 Git 다운로드 및 설치

깃(Git) 뽀개기① - GitHub 저장소 생성 및 Git 다운로드 및 설치하기 - 깃허브(GitHub)란? 개발 프로젝트에 참여하게 되었을 때 모든 개발을 나 혼자 하지는 않게 된다. 같은 소스를 여러 명이 수정할

yoni84.tistory.com

 

 

 


파이보에 깃 적용하기

 

(1단계) 파이보 프로젝트에서 저장소 만들기 - git init 

 

가장 먼저 할 일은 저장소(repository)를 만드는 것이다. projects/mysite에서 git init 명령을 실행하자. git init 명령은 가상 환경을 실행하지 않아도 된다. 

 

(mysite) D:\projects\mysite>git init
Initialized empty Git repository in D:/projects/mysite/.git/

(mysite) D:\projects\mysite>

 

그러면 D:\projects\mysite\.git\ 디렉터리가 생성된다. 이후 깃의 관리는 모두 이 디렉터리에서 이루어진다. 

 

※ .git 디렉터리가 보이지 않는다면?

윈도우 탐색기의 [보기] 메뉴에서 '숨긴 항목' 옵션을 체크해서 선택해 보자.

 

명령 실행 전
명령 실행 후 (git init 후)

 

 

(2단계) 현재 저장소의 상태 확인하기 - git status

 

rojects/mysite에서 git status 명령을 실행해 보자.

 

(mysite) D:\projects\mysite>git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .idea/
        common/
        config/
        db.sqlite3
        manage.py
        pybo/
        static/
        templates/

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

(mysite) D:\projects\mysite>

 

git status 명령은 현재 저장소의 상태를 출력한다. 또 아직 관리되지 않는 파일(untracked files)을 보여 주며, 이 파일을 관리하려면 git add 명령을 이용하라고 조언한다.

 

 

(3단계) 깃으로 관리하지 않을 파일 무시하기 - .gitignore

 

git add 명령을 수행하기 전에 깃으로 관리할 파일을 고민해야 한다. 예를 들어 파이보를 만들며 직접 작성한 mysite, pybo 디렉터리 등은 깃으로 관리해야 할 대상이 맞지만 .idea나 db.sqlite3 파일은 사용자별, 시스템별로 달라지는 파일이므로 깃으로 관리하면 안 된다.

 

※ .idea는 사용자 설정을 저장하는 파이참 전용 파일, db.sqlite3 파일은 SQLite의 데이터베이스 파일이다.

 

예를 들어 여러 명이 같은 저장소에서 작업할 때 .idea 파일을 누군가 변경한다면 내가 설정했던 파이참 설정 내용이 다른 사람의 것으로 변경되는 문제가 발생한다. 이런 문제를 방지하기 위해 .gitignore 파일을 작성하여 관리하지 않을 대상을 기술해줘야 한다. 다음처럼 .gitignore 파일을 생성해 보자.

 

# D:\projects\mysite\.gitignore (New)
 
.idea
db.sqlite3
*.pyc
__pychche__

 

컴파일된 파이썬 파일인 *.pyc와 __pychche__ 디렉터리도 깃으로 관리되지 않도록 .gitignore 파일에 추가해 주었다.

 

 

(4단계) 파일을 깃에 등록하기 - git add

 

이제 다음처럼 add 명령을 수행해 보자.

 

(mysite) D:\projects\mysite>git add *
warning: LF will be replaced by CRLF in static/bootstrap.min.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/bootstrap.min.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/jquery-3.6.1.min.js.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/KeditorPhotosEditor.min.js.다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/content.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/editor-content(1).css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/editor-content.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/editor-mobile-content.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/editor-plugins.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/font.css.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(10).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(12).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(19).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(2).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(3).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(4).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js(5).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/plugin.min.js.다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/post-editor.min.js.다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/saved_resource.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/tiara.min.js(1).다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/tiara.min.js.다운로드.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in static/글쓰기_files/tinymce.min.js.다운로드.
The file will have its original line endings in your working directory

(mysite) D:\projects\mysite>

 

현재 디렉터리 하위의 모든 파일을 추가하기 위해 git add * 를 수행했다. bootstrap.min.css, bootstrap.min.js, jquery-3.4.1.min.js 의 경고 문구는 '줄바꿈 문자를 \n에서 \r\n으로 강제로 바꾼다'는 의미이므로 무시해도 된다. 

 

 

git status 명령을 수행해 보자. 그러면 깃 스테이지 영역에 추가된 파일을 확인할 수 있다.

 

(mysite) D:\projects\mysite>git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   .gitignore
        new file:   common/__init__.py
        new file:   common/admin.py
        new file:   common/apps.py
        new file:   common/forms.py
        new file:   common/migrations/__init__.py
        new file:   common/models.py
        new file:   common/tests.py
        new file:   common/urls.py
        new file:   common/views.py
        new file:   config/__init__.py
        new file:   config/asgi.py
        new file:   config/settings.py
        new file:   config/urls.py
        new file:   config/wsgi.py
        new file:   manage.py
        new file:   pybo/__init__.py
        new file:   pybo/admin.py
        new file:   pybo/apps.py
        new file:   pybo/forms.py
        new file:   pybo/migrations/0001_initial.py
        new file:   pybo/migrations/0002_question_author.py
        new file:   pybo/migrations/0003_answer_author.py
        new file:   pybo/migrations/0004_auto_20220919_0923.py
        new file:   pybo/migrations/0005_comment.py
        new file:   pybo/migrations/0006_auto_20220927_0959.py
        new file:   pybo/migrations/__init__.py
        new file:   pybo/models.py
        new file:   pybo/templatetags/pybo_filter.py
        new file:   pybo/tests.py
        new file:   pybo/urls.py
        new file:   "pybo/views.py_\354\202\255\354\240\234"
        new file:   pybo/views/answer_views.py
        new file:   pybo/views/base_views.py
        new file:   pybo/views/comment_views.py
        new file:   pybo/views/question_views.py
        new file:   pybo/views/vote_views.py
        new file:   static/bootstrap.min.css
        new file:   static/bootstrap.min.js
        new file:   static/jquery-3.6.1.min.js
        new file:   static/style.css
        new file:   "static/\352\270\200\354\223\260\352\270\260.html"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/KeditorPhotosEditor.min.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/KeditorPhotosEditor.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/atom-one-light.min.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/content.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/editor-content(1).css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/editor-content.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/editor-mobile-content.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/editor-plugins.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/font.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img(1).png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img(2).png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img(3).png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img(4).png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img(5).png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img(6).png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/img.png"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/ko_KR.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(1).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(10).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(11).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(12).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(13).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(14).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(15).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(16).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(17).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(18).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(19).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(2).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(20).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(21).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(22).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(23).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(24).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(25).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(26).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(3).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(4).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(5).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(6).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(7).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(8).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(9).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/polyfill.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/post-editor.min.css"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/post-editor.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/saved_resource.html"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/theme.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/tiara.min.js(1).\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/tiara.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   "static/\352\270\200\354\223\260\352\270\260_files/tinymce.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
        new file:   templates/base.html
        new file:   templates/common/login.html
        new file:   templates/common/signup.html
        new file:   templates/form_errors.html
        new file:   templates/navbar.html
        new file:   templates/pybo/answer_form.html
        new file:   templates/pybo/comment_form.html
        new file:   templates/pybo/question_detail.html
        new file:   templates/pybo/question_form.html
        new file:   templates/pybo/question_list.html
        new file:   templates/pybo/standard.html


(mysite) D:\projects\mysite>

 

※ 깃이 저장소에 변경 사항을 저장할 때는 스테이징을 거친다.

깃은 저장소에 변경 사항을 바로 저장하지 않고 스테이징(staging)이라는 단계를 거친다. 스테이징은 변경 사항을 저장소에 저장하기 직전 단계를 올려놓는 개념이다. 따라서 git add <파일명> 명령을 사용하면 git add 명령으로 지정한 파일이 스테이지 영역에 추가되고, 이후 git commit 명령을 수행해야 비로소 스테이지 영역에 있는 파일이 저장소에 저장된다.

 

 

(5단계) 커밋하고 이메일 주소와 사용자명 등록하기 - git commit, git config

 

이제 git commit 명령을 수행하여 변경된 사항을 저장해 보자. -m 옵션은 커밋의 내용을 입력하는 옵션이다. 이 옵션을 생략 하면 커밋의 내용을 입력하는 에디터 창이 나타난다. 

 

(mysite) D:\projects\mysite>git commit -m "파이보 프로젝트 최초 커밋"
[master (root-commit) 19a48bf] 파이보 프로젝트 최초 커밋
 105 files changed, 6350 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 common/__init__.py
 create mode 100644 common/admin.py
 create mode 100644 common/apps.py
 create mode 100644 common/forms.py
 create mode 100644 common/migrations/__init__.py
 create mode 100644 common/models.py
 create mode 100644 common/tests.py
 create mode 100644 common/urls.py
 create mode 100644 common/views.py
 create mode 100644 config/__init__.py
 create mode 100644 config/asgi.py
 create mode 100644 config/settings.py
 create mode 100644 config/urls.py
 create mode 100644 config/wsgi.py
 create mode 100644 manage.py
 create mode 100644 pybo/__init__.py
 create mode 100644 pybo/admin.py
 create mode 100644 pybo/apps.py
 create mode 100644 pybo/forms.py
 create mode 100644 pybo/migrations/0001_initial.py
 create mode 100644 pybo/migrations/0002_question_author.py
 create mode 100644 pybo/migrations/0003_answer_author.py
 create mode 100644 pybo/migrations/0004_auto_20220919_0923.py
 create mode 100644 pybo/migrations/0005_comment.py
 create mode 100644 pybo/migrations/0006_auto_20220927_0959.py
 create mode 100644 pybo/migrations/__init__.py
 create mode 100644 pybo/models.py
 create mode 100644 pybo/templatetags/pybo_filter.py
 create mode 100644 pybo/tests.py
 create mode 100644 pybo/urls.py
 create mode 100644 "pybo/views.py_\354\202\255\354\240\234"
 create mode 100644 pybo/views/answer_views.py
 create mode 100644 pybo/views/base_views.py
 create mode 100644 pybo/views/comment_views.py
 create mode 100644 pybo/views/question_views.py
 create mode 100644 pybo/views/vote_views.py
 create mode 100644 static/bootstrap.min.css
 create mode 100644 static/bootstrap.min.js
 create mode 100644 static/jquery-3.6.1.min.js
 create mode 100644 static/style.css
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260.html"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/KeditorPhotosEditor.min.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/KeditorPhotosEditor.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/atom-one-light.min.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/content.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/editor-content(1).css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/editor-content.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/editor-mobile-content.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/editor-plugins.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/font.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img(1).png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img(2).png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img(3).png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img(4).png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img(5).png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img(6).png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/img.png"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/ko_KR.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(1).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(10).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(11).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(12).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(13).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(14).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(15).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(16).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(17).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(18).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(19).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(2).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(20).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(21).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(22).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(23).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(24).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(25).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(26).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(3).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(4).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(5).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(6).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(7).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(8).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js(9).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/plugin.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/polyfill.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/post-editor.min.css"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/post-editor.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/saved_resource.html"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/theme.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/tiara.min.js(1).\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/tiara.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 "static/\352\270\200\354\223\260\352\270\260_files/tinymce.min.js.\353\213\244\354\232\264\353\241\234\353\223\234"
 create mode 100644 templates/base.html
 create mode 100644 templates/common/login.html
 create mode 100644 templates/common/signup.html
 create mode 100644 templates/form_errors.html
 create mode 100644 templates/navbar.html
 create mode 100644 templates/pybo/answer_form.html
 create mode 100644 templates/pybo/comment_form.html
 create mode 100644 templates/pybo/question_detail.html
 create mode 100644 templates/pybo/question_form.html
 create mode 100644 templates/pybo/question_list.html
 create mode 100644 templates/pybo/standard.html

(mysite) D:\projects\mysite>

 

git commit 명령을 처음 수행하는 것이면 먼저 이메일 주소와 사용자명을 설정하라는 오류가 발생한다. 이럴 경우 다음을 참조하여 이메일 주소와 사용자명을 본인의 것으로 설정해 보자.

 

(mysite) D:\projects\mysite>git config --global user.email "OOO@gmail.com"
(mysite) D:\projects\mysite>git config --global user.name "[사용자명]"

 

☞ Git 환경설정 참고

 

[깃(Git) 뽀개기②] 깃(Git) 환경설정 및 깃허브(GitHub)로 소스 올리는 방법 (소스추가, 소스수정)

깃(Git) 뽀개기② - Git 환경설정 및 GitHub로 소스 체크인하는 방법 - 0. Git 환경설정 $ git config --global user.name "[USER NAME]"  --유저명입력 유저명을 입력한다. $ git config --global user.email "..

yoni84.tistory.com

 

 

이제 다시 git status 명령을 수행해 보자.

 

(mysite) D:\projects\mysite>git status
On branch master
nothing to commit, working tree clean

(mysite) D:\projects\mysite>

 

변경 사항이 없으며 작업 공간이 깨끗하다는 정보를 확인할 수 있다.

 


 

 

 

 


파이보에 깃 적용하기 (이어서...)

 

 

 

(6단계) templates/base.html 수정해 보기

 

이번에는 base.html 템플릿 파일의 <tilte>을 수정하여 저장해 보자.

 

# D:\projects\mysite\templates\base.html

(.. 생략...)
    <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
    <title>파이보</title>
(.. 생략...)

 

 

그리고 다시 git status 명령을 수행해 보자.

 

(mysite) D:\projects\mysite>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:   templates/base.html

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

(mysite) D:\projects\mysite>

 

파일을 변경하고 git status 명령을 수행하면 이와 같은 변경 내역 정보가 표시된다.

 

 

(7단계) 코드의 변경 내역 확인하고 한글 문제 해결하기 - git diff

 

코드의 변경 내역을 확인하려면 git diff 명령을 실행하면 된다.

 

(mysite) D:\projects\mysite>git diff
diff --git a/templates/base.html b/templates/base.html
index 68ba64c..06a511b 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -9,7 +9,7 @@
     <link rel="stylesheet" type="text/css" href="{% static 'bootstrap.min.css' %}">
     <!-- pybo CSS -->
     <link rel="stylesheet" type="text/css" href="{% static 'style.css' %}">
-    <title>Hello, pybo!</title>
+    <title>파이보</title>
 </head>
 <body>
 {% include "navbar.html" %}

(mysite) D:\projects\mysite>

 

※ git diff 명령을 수행하면 한글이 모두 깨져 보이는 문제가 발생한다면?

다음처럼 set LC_ALL=C.UTF-8 명령을 수행하면 된다.

 

(mysite) D:\projects\mysite>set LC_ALL=C.UTF-8

 

그리고 다시 git diff 명령을 실행하면 한글이 제대로 출력되는 것을 확인할 수 있다. git diff 명령으로 출력되는 문장에서 (-) 표시는 삭제되는 부분이고 (+)표시는 추가되는 부분을 의미한다.

 

 

(8단계) 코드의 변경 내역 되돌리기 - git restore

 

만약 코드의 변경 내역을 되돌리고 싶을 때는 git restore 명령을 수행하면 된다.

 

(mysite) D:\projects\mysite>git restore templates/base.html

(mysite) D:\projects\mysite>

 

git restore 명령 뒤에는 되돌리고 싶은 파일명을 적으면 된다. 파일 이름은 git status 명령으로 출력된 파일명을 기준으로 적으면 된다. 파이참에서 확인해 보면 변경한 내용이 이전 내용으로 복구된 것을 확인할 수 있다. (git status 명령으로 확인 가능)

 

 

(9단계) 변경 내역 커밋하기 - git commit -a

 

복구된 templates/base.html 파일의 코드를 다시 <title>파이보</title>로 변경하고 git commit 명령을 수행해 보자.

 

(mysite) D:\projects\mysite>git commit -m "타이틀 변경"
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:   templates/base.html

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

(mysite) D:\projects\mysite>

 

그러면 '변경 내역이 저장되지 않았다'는 메시지와 함께 git add 명령 또는 git commit -a 명령을 수행하라는 메시지가 나타난다. 만약 변경 내역을 커밋하고 싶다면 get add 명령을 진행하고 git commit 명령을 수행하거나 git commit 명령에 -a 옵션을 추가해야 한다. -a 옵션은 커밋할 때 add 명령도 함께 처리하라는 옵션이다. 다음처럼 -a 옵션을 추가하여 변경 내역을 적용하자. 

 

(mysite) D:\projects\mysite>git commit -a -m "타이틀 변경"
[master a319467] 타이틀 변경
 1 file changed, 1 insertion(+), 1 deletion(-)

(mysite) D:\projects\mysite>

 

 

(10단계) 커밋 이력 확인하기 - git log  

 

깃으로 커밋한 이력을 확인하려면 git log 명령을 입력하면 된다.

 

(mysite) D:\projects\mysite>git log
commit a3194674b97d285a7bc6f1b7fdd5cdaf95cc3f85 (HEAD -> master)
Author: Yoni33333 <bbonara84@gmail.com>
Date:   Tue Oct 11 10:28:42 2022 +0900

    타이틀 변경

commit 19a48bfbe49ac656e42055b7ee43799c5d11c50a
Author: Yoni33333 <bbonara84@gmail.com>
Date:   Tue Oct 11 10:07:15 2022 +0900

    파이보 프로젝트 최초 커밋

(mysite) D:\projects\mysite>

 

 

 


 

여기까지.

 

 

 

 

 

 

댓글