이번 포스트에서는 github 에 프로젝트를 업로드하고 다운받아보겠습니다.
초기설정
먼저 git 프로젝트를 업로드할 company 디렉토리와 다운로드 받을 home 디렉토리를 각각 만듭니다.
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace
$ mkdir company
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace
$ mkdir home
다음으로 github 에 Repository 를 생성합니다.
push
company 디렉토리에서 프로젝트설정.txt 파일을 만들고 commit 합니다.
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company
$ git init
Initialized empty Git repository in C:/Users/TEST/Desktop/git_workspace/company/.git/
g
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company (master)
$ touch 프로젝트설정.txt
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company (master)
$ git add .
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company (master)
$ git commit -m "프로젝트 설정"
[master (root-commit) e41478b] 프로젝트 설정
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "\355\224\204\353\241\234\354\240\235\355\212\270\354\204\244\354\240\225.txt"
github 연결
Repository 를 만들면 나오는 화면에서 위 주소를 복사해서 로컬 저장소를 github 와 연결합니다.
git remote add origin (주소)
(여기서 origin 은 원격 저장소를 뜻함.)
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company (master)
$ git remote add origin https://github.com/jeehwan-lee/myapp.git
git remote -v 를 통해 확인해보면 연결이 된 것을 볼 수 있습니다.
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company (master)
$ git remote -v
origin https://github.com/jeehwan-lee/myapp.git (fetch)
origin https://github.com/jeehwan-lee/myapp.git (push)
프로젝트 push
github 와 연결된 로컬저장소의 프로젝트를 github 로 업로드해보겠습니다.
git push origin (업로드할 브랜치명)
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/company (master)
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 6 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 244 bytes | 244.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/jeehwan-lee/myapp.git
* [new branch] master -> master
github 에 접속해서 F5 새로고침을 해보면 프로젝트가 업로드된것을 알 수 있습니다.
pull
다음으로 위에서 만든 home 디렉토리에서 github 의 프로젝트를 다운받아보겠습니다.
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/home
$ git init
Initialized empty Git repository in C:/Users/TEST/Desktop/git_workspace/home/.git/
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/home (master)
$ git remote add origin https://github.com/jeehwan-lee/myapp.git
git remote add origin (주소) 를 통해 github 와 연결을 합니다.
(이때 반드시 git init 명령어를 통해 초기화를 합니다.)
git pull origin (다운받을 브랜치명)
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/home (master)
$ git pull origin master
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 224 bytes | 28.00 KiB/s, done.
From https://github.com/jeehwan-lee/myapp
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
git pull origin 을 통해 github 에 업로드된 프로젝트를 다운받았습니다.
TEST@DESKTOP-6UMU4VH MINGW64 ~/Desktop/git_workspace/home (master)
$ ls -l
total 0
-rw-r--r-- 1 TEST 197121 0 Jan 3 10:36 프로젝트설정.txt
이 포스트는 유튜브에 올라온 메타코딩님의 Git 강의를 보고 정리한 내용입니다.
https://www.youtube.com/@metacoding
'Git' 카테고리의 다른 글
Git - rebase 를 통한 로그관리 (0) | 2023.01.09 |
---|---|
Git - clone 과 fetch (0) | 2023.01.03 |
Git - 3 way merge (0) | 2023.01.03 |
Git - fast forward merge (0) | 2023.01.03 |
Git - reset과 reflog를 통한 복구 (1) | 2022.12.31 |