ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [코드스테이츠 4-2_advanced] 데이터 기초반_파이썬 입문(과제: 4-2_advanced)
    [코드스테이츠] 2022. 11. 17. 17:22

    1. 과제명

    • 코드스테이츠 K-디지털 기초역량훈련 데이터 기초반 4-2(advanced)

     

    2. 과제내용

    • default branch 인 main 이외에 새로운 branch 를 생성하여 코드 분기점 관리를 해봐요.

     

    3. 과제를 통해 배운점

    • 4주 1일차에 작성했던 advanced 과제의 레포지토리에서 branch 를 사용해봐요.
    # 레포지토리에 올릴 폴더로 이동
    yeaqw@DESKTOP-AT39ET9 MINGW64 ~ 
    $ cd D:/jupyter_notebook/temp/my_first_repository
    
    # 현재 branch 확인
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ git checkout
    Your branch is up to date with 'origin/main'.
    
    # 새로운 branch 생성 및 이동
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ git checkout -b red_theme
    Switched to a new branch 'red_theme'
    
    # 파일 편집
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ vi new_file.txt
    
    # 편집한 파일 add
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git add new_file.txt
    
    # add한 파일 commit : commit 명 "theme changed"
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git commit -m "theme changed"
    [red_theme b0f9534] theme changed
     1 file changed, 3 insertions(+), 1 deletion(-)
    
    # main branch로 이동
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git checkout main
    Switched to branch 'main'
    Your branch is up to date with 'origin/main'.
    
    # 파일 확인: 변경 전 파일로 유지되어 있음
    # 파일 내용 수정
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ vi new_file.txt
    
    # 수정한 파일 main branch에서 add
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ git add new_file.txt
    
    # add한 파일 commit
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ git commit -m "add a sentence in the line number 2"
    [main bd6e14c] add a sentence in the line number 2
     1 file changed, 3 insertions(+), 1 deletion(-)
    
    # red_theme branch로 이동
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ git checkout red_theme
    Switched to branch 'red_theme'
    
    # branch 상태 확인
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git status
    On branch red_theme
    nothing to commit, working tree clean
    
    # main branch에 있는 파일을 red_theme branch로 merge (합치기)
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git merge main
    Auto-merging new_file.txt
    CONFLICT (content): Merge conflict in new_file.txt
    Automatic merge failed; fix conflicts and then commit the result.
    # conflict 발생
    
    # conflict 발생 사항이 포함되어 있는 파일 확인 및 최종적으로 원하는 파일로 수정
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme|MERGING)
    $ vi new_file.txt
    
    # 수정 완료한 파일 add
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme|MERGING)
    $ git add new_file.txt
    
    # add한 파일 commit : commit 명 "solve the conflict"
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme|MERGING)
    $ git commit -m "solve the conflict"
    [red_theme 6354147] solve the conflict
    
    # branch 상태 확인
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git status
    On branch red_theme
    nothing to commit, working tree clean
    
    # 해당 branch 안의 new_file.txt 내용 확인
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ cat new_file.txt
    This is a new file.
    The theme of this file is red.
    This file modified.
    
    # main branch로 이동
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (red_theme)
    $ git checkout main
    Switched to branch 'main'
    Your branch is ahead of 'origin/main' by 1 commit.
      (use "git push" to publish your local commits)
    
    # main branch의 new_file.txt 내용 확인: 수정 확인 전 내용
    yeaqw@DESKTOP-AT39ET9 MINGW64 /d/jupyter_notebook/temp/my_first_repository (main)
    $ cat new_file.txt
    This is my file.
    This file modified.
    The theme of this file is green.

    댓글

Designed by Tistory.