ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Remote repository와 Local repository를 연결해보기
    Git 2022. 9. 17. 19:30

    # Local repository의 내용을 Remote repository에 반영하기

    # github repository를 하나 만들어 보자 
    
    
    
    깃허브의 레포지토리 
    => 원격 레포지토리 or 리모트 레포지토리
    
    
    내 컴퓨터의 레포지토리 
    => 로컬 레포지토리 
    
    ==================
    
    로컬 레포지토리를 깃허브의 레포지토리에 업로드 해보자 
    
    # 로컬 레포지토리를 만들고 커밋을 한 후에 깃허브에 업로드하기
    …or create a new repository on the command line
    echo "# Git_Practice" >> README.md
    git init
    git add README.md
    git commit -m "first commit"
    git branch -M main
    git remote add origin https://github.com/yunajoe/Git_Practice.git
    git push -u origin main
    
    
    
    # 이미 만든 로컬 레포지토리를 깃허브에 업로드하기 
    …or push an existing repository from the command line
    git remote add origin https://github.com/yunajoe/Git_Practice.git
    git branch -M main
    git push -u origin main
    
    ===========================
    
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ git remote add origin https://github.com/yunajoe/Git_Practice.git
    
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ git push -u origin master
    Enumerating objects: 10, done.
    Counting objects: 100% (10/10), done.
    Delta compression using up to 12 threads
    Compressing objects: 100% (7/7), done.
    Writing objects: 100% (10/10), 757 bytes | 757.00 KiB/s, done.
    Total 10 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/yunajoe/Git_Practice.git
     * [new branch]      master -> master
    branch 'master' set up to track 'origin/master'.

    2 comits를 눌렀을때

     

    +는 추가 된 코드, -는 삭제된 코드

    # Local repository의 바뀐내용을 Remote repository에 반영하기

    git push

    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ ls
    License  README.md  calculator.py  meeting-log/
    
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ git add .
    
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ git commit -m "Create REAME.me"
    [master 7bcb609] Create REAME.me
     1 file changed, 1 insertion(+)
    
    ===============================
    Local repository 변경내용을 Remote repository로 반영하기 
    
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ git push
    Enumerating objects: 4, done.
    Counting objects: 100% (4/4), done.
    Delta compression using up to 12 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 380 bytes | 380.00 KiB/s, done.
    Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://github.com/yunajoe/Git_Practice.git
       d5881c1..7bcb609  master -> master

    # Remote repository 변경내용을 local repository로 반영하기 

    git pull

    Remote repository 변경내용을 local repository로 반영하기 
    git pull 
    
    README.md를 수정해주자 
    
    Remote repository의 commit이 local repository의 commit수보다 1개 더 앞서있다
    
    
    
    
    
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ git pull
    remote: Enumerating objects: 5, done.
    remote: Counting objects: 100% (5/5), done.
    remote: Compressing objects: 100% (3/3), done.
    remote: Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
    Unpacking objects: 100% (3/3), 709 bytes | 101.00 KiB/s, done.
    From https://github.com/yunajoe/Git_Practice
       7bcb609..cfe4b0b  master     -> origin/master
    Updating 7bcb609..cfe4b0b
    Fast-forward
     README.md | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
    
    # 학인해보기 
    yunajoe@yunajoe MINGW64 ~/Git/MathTool (master)
    $ cat README.md
    ### Git Bash 연습입니당
    1. calculator.py => 계산기 모듈

     

     

    local -> Remote 

    git remote add origin https://github.com/yunajoe/Git_Practice.git

    git push -u origin master

    ============================
    local repository에 커밋하자 

    git add 'push하려고하는 .py' 
    git commit -m '커밋메세지'
    ============================
    local repository에서 바뀐 내용을 remote repository로 변경하자 
    git push 
    ============================
    리모트 레포지토리 -> local 레포지토리 

    리모트 레포지토리에서 README.md를 바꿔준다 
    리모트 repository 가 로컬 repository보다 1commit 앞서고 있음 


    yunajoe@DESKTOP-ULNOHTM MINGW64 ~/Desktop/Git_Practice (master)
    $ git pull
    ============================
    반영한 걸 확인해보기 

    $ cat README.md
    ## Git Bash 연습 Repo입니다
    **1. calculator.py** => 계산기의 기능들을 제공하는 모듈

    1. retmoe repository 가 있으면 좋은 이유은?!
    - 안정성  
    - 협업가능 
    ============================
    git comnmand정리 

    1. 로컬 레포지토리의 내용을 처음으로 GitHub의 리모트 레포지토리로 보낼 때
    - git push --set-upstream origin master


    ============================

    댓글

Designed by Tistory.