본문 바로가기
JavaScript/└ [프로젝트] 웹 홈페이지 제작

git) git 설치, github 원격저장소로 업로드하기

by 박채니 2022. 6. 10.

안녕하세요, 코린이의 코딩 학습기 채니 입니다.

 

개인 포스팅용으로 내용에 오류 및 잘못된 정보가 있을 수 있습니다.


git 설치 주소

https://git-scm.com/download/win

 

Git - Downloading Package

Download for Windows Click here to download the latest (2.36.1) 32-bit version of Git for Windows. This is the most recent maintained build. It was released about 1 month ago, on 2022-05-09. Other Git for Windows downloads Standalone Installer 32-bit Git f

git-scm.com

 

컴퓨터의 운영체제에 맞는 파일을 다운로드 받아주고, 모두 기본 값을 Next를 눌러줍니다.

 

다운로드가 완료 되면 Git Bash를 실행!


$ pwd

- 현재 자신이 어떤 경로에 위치해있는 지 확인

컴퓨터이름@DESKTOP-K88T93L MINGW64 ~ (master)
$ pwd
/c/Users/컴퓨터이름

저는 현재 c드라이브 하위에 Users하위에 컴퓨터이름 폴더에 있습니다.

 

이를 프로젝트를 생성한 폴더로 이동시켜줍니다.

cd 키워드 이용!

사용자이름@DESKTOP-K88T93L MINGW64 ~ (master)
$ cd ../../Workspaces

사용자이름@DESKTOP-K88T93L MINGW64 /c/Workspaces (master)
$ ls
helloworld_workspace/  oracle_scottsql    uml_workspace/
java_workspace/        oracle_workspace/  views/
jdbc_workspace/        resources/         web_client_workspace/

 

사용자이름@DESKTOP-K88T93L MINGW64 /c/Workspaces (master)
$ cd web_client_workspace/parkchaeeun

$ pwd
/c/Workspaces/web_client_workspace/parkchaeeun

해당 폴더로 잘 이동한 것을 확인할 수 있습니다.

 

$ git init

- 현재 디렉토리를 지역 저장소로 설정

$ git init
initialized empty Git repository in C:/Workspaces/web_client_workspace/parkchaeeun/.git/

사용자이름@DESKTOP-K88T93L MINGW64 /c/Workspaces/web_client_workspace/parkchaeeun (master)

 

$ ls
css/        introduce.html  login.html        myPage.html
image/      join.html       managerMain.html  roadmap.html
index.html  js/             managerPage.html  travel.html

폴더 하위에 존재하는 디렉토리/파일들을 모두 조회할 수 있습니다.

 

$ ls -a (all 조회)

$ ls -a
./     css/        introduce.html  login.html        myPage.html
../    image/      join.html       managerMain.html  roadmap.html
.git/  index.html  js/             managerPage.html  travel.html

.git 디렉토리도 확인할 수 있습니다.

어떤 사용자가 버전을 남겼는 지에 대한 사인할 아이디와 이메일이 필요합니다.

확인 방법

$ git config --list

$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.name=
user.email=
difftool.sourcetree.cmd='' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd=''
mergetool.sourcetree.trustexitcode=true
credential.helperselector.selected=manager-core
core.repositoryformatversion=0
core.filemode=false
core.bare=false
:

처음 시작했다면 user.name과 user.email이 비어있을 것이며, 이를 등록해줘야 합니다.

 

$ git config --global user.name

$ git config --global user.email

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

$ git config --global user.email "chaeeun0119@naver.com"

 

등록이 잘 되었는 지 확인해보겠습니다.

$ git config --list

$ git config --list
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager-core
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
user.name=chaenyy
user.email=chaeeun0119@naver.com
difftool.sourcetree.cmd='' "$LOCAL" "$REMOTE"
mergetool.sourcetree.cmd=''
mergetool.sourcetree.trustexitcode=true
credential.helperselector.selected=manager-core
core.repositoryformatversion=0
core.filemode=false
core.bare=false
:

이제는 user.name과 user.email이 잘 등록 되어있는 것을 확인할 수 있습니다.

 

$ git status

- 변경 내역을 감지하여 변경된 파일을 보여줌

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   index.html
        modified:   introduce.html
        modified:   join.html
        modified:   login.html
        modified:   managerMain.html
        modified:   managerPage.html
        modified:   myPage.html
        modified:   roadmap.html
        modified:   travel.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        js/

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

변경이 감지된 파일들을 staging area에 올려주는 작업을 해줘야 합니다.

 

$ git add .

- 현재 디렉토리에 모든 파일을 staging area에 올려줌

$ git add .

 

잘 등록 되었는 지 확인해줍니다.

$ git status

$ git status
        new file:   index.html
        new file:   introduce.html
        new file:   join.html
        new file:   login.html
        new file:   managerMain.html
        new file:   managerPage.html
        new file:   myPage.html
        new file:   roadmap.html
        new file:   travel.html

(이미 commit 한 상태에서 확인하는 거라 정확하진 않지만, 초록색 글씨로 대충 위와 같이 출력됨!)

 

$ git commit -m "homepage project init!"

- 버전 생성

$ git commit -m "homepage project init!"
[master d20a617] homepage project init!
 18 files changed, 1217 insertions(+), 1229 deletions(-)
 create mode 100644 js/index.js
 create mode 100644 js/introduce.js
 create mode 100644 js/join.js
 create mode 100644 js/login.js
 create mode 100644 js/managerMain.js
 create mode 100644 js/managerPage.js
 create mode 100644 js/myPage.js
 create mode 100644 js/roadmap.js
 create mode 100644 js/travel.js

버전이 생성되는 것을 확인할 수 있습니다.

 

$ git log

- 버전 조회

$ git log

지역 저장소의 변경사항을 원격 저장소로 업로드

 

github의 저장소 생성하기

github - Your repositories - New - Repository name 설정 (아이디.github.io / chaenyy.github.io) - Create repository 

저장소를 생성하면 URL이 생성되고, 해당 URL을 copy합니다.

 

지역 저장소로 다시 돌아옴 (git bash)

 

$ git remote add 별칭 원격저장소URL

- 원격 저장소 등록

$ git remote add origin 원격저장소URL


$ git push origin master

- 지역 저장소의 변경사항을 원격 저장소로 push

- 인증을 요구할 시 브라우저에서 인증하기 선택!

$ git push origin master

Enumerating objects: 30, done.
Counting objects: 100% (30/30), done.
Delta compression using up to 8 threads
Compressing objects: 100% (21/21), done.
Writing objects: 100% (21/21), 10.33 KiB | 2.58 MiB/s, done.
Total 21 (delta 15), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (15/15), completed with 8 local objects.
To https://github.com/chaenyy/chaenyy.github.io.git
   65b0139..d20a617  master -> master

 

github 페이지를 새로고침하면 잘 등록 된 것을 확인할 수 있습니다.

깃헙ID.github.io로 접속하면 홈페이지 접속이 성공적으로 실행!