생활코딩

Coding Everybody

코스 전체목록

닫기

status의 원리

수업소개

여기서는 git status가 동작하는 원리를 알아봅니다. 특히 working directory와 index 그리고 repository의 관계를 분명하게 이해하는데 도움이 될 것 같습니다. 

수업

댓글

댓글 본문
  1. 박병진
    감사합니다.
  2. 주니어개발자
    working directory - index / staging area / cache - repository
  3. working copy, index, commit의 일치
  4. supernet
    완료!!!
  5. fish5542
    강의 잘봣습니다!
  6. PassionOfStudy
    -working directory
    - index, staging area, cache
    - repository

    3가지에 대해서 숙지하겠습니다.
  7. software.lee
    감사합니다.
  8. Deuklyoung Ko
    유용한 정보네요. 그 동안 형상관리 프로그램을 사용하면서 궁금했던 부분들이 많이 해소되었습니다.
  9. 제로스
    working directory - index, staging area - repository
    감사합니다.
  10. 고스트프리
    감사합니다.
  11. 정우희
    강의가 너무 좋습니다. 자바스크립트로 표현 해보았습니다.
    처음에는 hash가 주요한 식별자인 줄 알았는데, file명이 유저 입장에서의 식별자이더군요.

    (a javascript playground)
    Suppose git's main thread object is 'git'. Almost all objects and their methods are fake but plausible.

    var untrackedFiles = [];
    var changesNotStagedForCommit = [];
    var changesToBeCommittedNew = [];
    var changesToBeCommittedModified = [];

    var allFiles = git.getFiles();
    var lastCommit = git.getLastCommit();
    var lastCommitPoint = lastCommit.getCreated();
    var index = git.getIndex();

    for (var file in allFiles){
    if (file.lastModified() > lastCommitPoint){
    var fileName = file.getName();
    var stagedFile = index.getFileByName(fileName);
    if (stagedFile === null){
    untrackedFiles.push(file);
    } else {
    var hash = Sha1.hash(file.getBlob());
    var stagedHash = stagedFile.getHash();
    if (stagedHash !== hash){
    changesNotStagedForCommit.push(file);
    } else {
    if (!git.checkBinaryEquality(stagedFile, file)){ // all hash functions are many-to-one
    throw new Error("collision message~"); // i do not know the real strategy of Git;;;
    }
    var committedFile = lastCommit.getTree().getFileByName(fileName);
    if (committedFile === null){
    changesToBeCommittedNew.push(file);
    } else {
    var committedHash = committedFile.getHash();
    if (committedHash !== hash){
    changesToBeCommittedModified.push(file);
    } else {
    // nothing to do
    // no collision check because the commit process uses the same object at addition to the index even the file modifed after addtion.
    }
    }
    }
    }
    }
    }

    // another loop for deletion check is omitted.
  12. haMsa
    감사합니다.
  13. 원리를 이해하니까 재미있네요
  14. asdf
    질문 있습니다!

    status를 할경우 index에 없는 즉, add를 한적 없는것도 판단하는것이 아닌지요?
    그런 경우에는 다른 방법으로 판단하는 것인지요?
  15. Anes Seo
    원리를 보니까 신기하고 재미있네요. 좋은 강의 만들어 주셔서 고맙습니다.
  16. groundntree
    * f2.txt 파일 수정 / add / commit 시점의 status 상태 알아보기
    vim f2.txt
    git status
    git add f2.txt
    git status
    git commit
    git status
  17. 이보나
    항상 감사함당
graphittie 자세히 보기