버전 생성 및 변경사항 조회하기 - 최초 파일 생성 후 버전관리 목록에 추가하기, 버전관리 되고 있는 파일내용 변경, 하나의 버전에 여러 개의 파일 추가하기

CODEDRAGON Development/Git, PM

반응형

 

 

버전 생성 및 변경사항 조회하기

·       TODO 1: 최초 파일 생성 후 버전관리 목록에 추가하기

·       TODO 2: 버전관리 되고 있는 파일내용 변경

·       TODO 3: 하나의 버전에 여러 개의 파일 추가하기

 

 

 

TODO 1: 최초 파일 생성 후 버전관리 목록에 추가하기

 

저장소의 상태 확인하기

git status


 

"Untracked files: "항목에 나와 있는 목록들은 아직 git이 버전관리를 하고 있지 않은 파일 들을 보여줍니다.

저장소를 만들면 그 안에 있는 파일들이 자동으로 관리되는 것이 아니라 어떤 파일을 버전관리할 지 git 명령어로 알려주어야 합니다.

$ git status

On branch master

 

Initial commit

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

 

        index.html

 

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

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

 

git의 버전관리 목록에 파일 추가하기

git add index.html


 

추가한 새 파일인 index.html이 버전관리 대상이 된 것을 확인할 수 있습니다.

초록색으로 보이는 파일 목록은 commit명령을 실행하여 버전관리 목록에 추가합니다.

git status


 

 

git commit -m 'add index.html'

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git commit -m 'add index.html'

[master (root-commit) 1e14a20] add index.html

 1 file changed, 10 insertions(+)

 create mode 100644 index.html

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

1 file changed, 10 insertions(+)

한 개의 파일이 추가(변경)되었고 그 파일에는 10개의 줄이 추가되었다는 의미입니다.

 

 

아래처럼 메시지가 나오면 사용자의 email name정보를 등록해 주시기 바랍니다.

hbh1@hbh1-PC MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git commit -m 'add index.html'

 

*** Please tell me who you are.

 

Run

 

  git config --global user.email "you@example.com"

  git config --global user.name "Your Name"

 

to set your account's default identity.

Omit --global to set the identity only in this repository.

 

fatal: unable to auto-detect email address (got 'hbh1@hbh1-PC.(none)')

 

 

 

git config --global user.email "codedragon@tistory.com"

git config --global user.name "codedragon"

hbh1@hbh1-PC MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git config --global user.email "codedragon@tistory.com"

 

hbh1@hbh1-PC MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git config --global user.name "codedragon"

 

hbh1@hbh1-PC MINGW64 /c/CodeLab/gitLab/hellogit (master)

 

 

 

git status


 

"nothing to commit, working tree clean"로 표시되며 여러분의 모든 파일들이 git의 버전관리에 추가 및 적용되어 있기 때문에 더 이상 버전을 만들것이 없다는 의미입니다.

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git status

On branch master

nothing to commit, working tree clean

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

 

git 버전 확인하기

commit 명령어 수행시 입력한 메시지와 함께 버전 정보가 보입니다.

git log


 

 

 

 

TODO 2: 버전관리 되고 있는 파일내용 변경

 

소스파일에 코드 추가하기

<h1>Hello git</h1>


 

git status


 

빨간색으로 index.html파일이 tracted 되고 있는 상태이며 수정된 상태라는 것을 표시해 줍니다.

Changes not staged for commit: 상태에서는 commit해도 git에 반영되지 않습니다.

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git status

On branch master

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git checkout -- <file>..." to discard changes in working directory)

 

        modified:   index.html

 

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

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

파일의 변경 사항을 버전에 추가하기

git add index.html

git status


 

해당 파일이 초록색으로 바뀌며 modified된 상태로 표시됩니다.

Changes to be committed: 상태이면 commit 명령을 수행하게 되면 해당 파일의 변경 내용이 git의 버전에 추가되게 됩니다.

$ git add index.html

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git status

On branch master

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)

 

        modified:   index.html

 

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

git 버전 생성하기

git commit -m 'add code Hello git'


 

git status


 

 

버전 생성 확인하기

버전이 추가된 것을 확인할 수 있습니다.

git log


 

 

 

 

 

TODO 3: 하나의 버전에 여러 개의 파일 추가하기

 

 

새로운 파일 생성하기

style.css



 

 

style.css


 

body{

color: red;

}

 

 

index.html

<link rel="stylesheet" href="style.css" charset="UTF-8">


 


 

 

git status


 

버전에 추가한 파일인 index.html은 수정된 상태이고

새로 추가한 파일인 style.css는 아직 추적(tracted)되고 있지 않은 상태인 것을 확인할 수 있습니다.

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git status

On branch master

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git checkout -- <file>..." to discard changes in working directory)

 

        modified:   index.html

 

Untracked files:

  (use "git add <file>..." to include in what will be committed)

 

        style.css

 

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

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

새로 생성한 파일을 git의 버전관리 대상에 추가하기

git add style.css

git status

 


 

style.css new file로 된것을 확인할 수 있습니다.

초록색이므로 commit을 하게 되면 git의 버전에 추가되게 됩니다.

빨간색인 index.html add로 버전관리 대상에 추가시키지 않았으므로 add명령어로 추가해 주어야 git의 버전에 추가되게 됩니다.

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git add style.css

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git status

On branch master

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)

 

        new file:   style.css

 

Changes not staged for commit:

  (use "git add <file>..." to update what will be committed)

  (use "git checkout -- <file>..." to discard changes in working directory)

 

        modified:   index.html

 

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

수정한 index.html파일을 버전 대상에 추가하기

git add index.html

git status

 

두 파일 모두 초록색으로 표시되어 두 파일의 변경사항이 새로운 버전관리 대상이 된 것을 확인할 수 있습니다.

commit을 수행하게되면 두개의 파일에서 생성된 변경사항이 모두 버전에 추가됩니다.

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git add index.html

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git status

On branch master

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)

 

        modified:   index.html

        new file:   style.css

 

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

 

새로운 버전 생성하기

git commit -m 'add style.css'


 

두 개의 파일이 changed되었다고 표시됩니다.

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$ git commit -m 'add style.css'

[master 7f927e1] add style.css

 2 files changed, 4 insertions(+)

 create mode 100644 style.css

 

codedragon@CODEMASTER MINGW64 /c/CodeLab/gitLab/hellogit (master)

$

 

 

git log


 

반응형