Github 셋팅 및 기능들
Github를 편하게 써보자
오늘은 깃허브 터미널을 통해 파일을 저장하는 방법에 대해 알아보려고 합니다.
그 전에 왜 이 방법을 사용하면 더 좋은지 그 장점에 대해서 몇가지 설명드릴게요!
① 효율적인 작업 관리: 터미널을 사용하면 명령어를 통해 Git 작업을 더 효율적으로 관리할 수 있습니다. 예를 들어, 파일을 추가하거나 커밋을 하고 push하는 과정을 명령어 몇 개로 간단히 처리할 수 있습니다.
② 자동화 및 스크립팅: 터미널을 사용하면 작업을 자동화하고 스크립트를 작성하여 반복 작업을 간편하게 처리할 수 있습니다. 특히 복잡한 작업이나 반복적인 작업을 자동화하면 시간을 절약할 수 있습니다.
③ 원격 서버 작업: 원격 서버에 접속하여 Git 작업을 할 때 터미널을 사용하는 것이 편리합니다. SSH를 통해 원격 서버에 접속하여 Git 명령어를 실행할 수 있습니다.
④ 문제 해결 및 디버깅: 터미널을 사용하면 Git 작업 중 발생하는 문제를 빠르게 해결하고 디버깅할 수 있습니다. 에러 메시지를 확인하고 문제를 신속하게 해결할 수 있습니다.
⑤ 커맨드 라인 인터페이스(CLI) 경험: 터미널을 사용하면 커맨드 라인 인터페이스(CLI)를 익히는데 도움이 됩니다. CLI는 다양한 프로그래밍 및 시스템 관리 작업에서 유용하게 사용되므로, CLI에 익숙해지면 다양한 작업을 더 쉽게 처리할 수 있습니다.
Github 초기 설정
▶ 깃허브는 커밋을 할 때 마다 사용자 정보를 기록하고, 편집기 설정에 따라 메시지를 작성할 수 있습니다.
터미널(명령프롬프트)에서 Github 버전 확인하기
▶ Github이 설치되어 있는지 확인하려면 터미널(명령 프롬프트)에서 아래 명령을 실행합니다.
만약 Github이 설치되어 있지 않다면 해당 명령을 실행할 수 없으니 설치가 필요한 경우, 공식 Github 웹사이트에서 다운로드하여 설치합니다.
1
2
C:\Users\line>git version
git version 2.44.0.windows.1
터미널(명령프롬프트)에서 내 계정정보 확인하기
▶ git config –list를 입력하여 내 name과 email이 맞는지 확인합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
C:\Users\line>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/etc/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
user.name=hyunminkim93
user.email=163365140+HwangInJi@users.noreply.github.com
▶ 만약 name과 email이 내 정보가 아니라면 따로 변경을 해주어야합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
git config --global user.name "HwangInJi" -> 이름 변경
git config --global user.email "dlswl1993@gmail.com" -> 이메일 변경
C:\Users\line>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/etc/ssl/certs/ca-bundle.crt
core.autocrlf=true
core.fscache=true
core.symlinks=false
pull.rebase=false
credential.helper=manager
credential.https://dev.azure.com.usehttppath=true
init.defaultbranch=master
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
user.name=HwangInJi
user.email=dlswl1993@gmail.com
commit 해야할 파일 확인 및 commit하기
▶ git status를 입력하여 변경된 파일 확인
- 터미널에서 빨간색으로 표시된 부분이 변경된 파일
1
2
3
4
5
6
7
8
9
10
11
12
13
14
C:\Users\line\Documents\GitHub\class2024>git status
On branch main
Your branch is up to date with 'origin/main'.
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: json/gineungsaJC2024_01.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
effect/
no changes added to commit (use "git add" and/or "git commit -a")
▶ git add .를 입력하여 commit할 모든 파일 업로드 대기시킨 후 git status로 확인
- 터미널에서 초록색으로 표시된 부분이 commit대기중인 파일
1
2
3
4
5
6
7
8
9
10
C:\Users\line\Documents\GitHub\class2024>git add .
C:\Users\line\Documents\GitHub\class2024>git status
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: effect/index.html
modified: json/gineungsaJC2024_01.json
▶ git commit -m “저장명”을 입력하여 commit할 파일명 지정
1
2
3
4
C:\Users\line\Documents\GitHub\class2024>git commit -m "2024.04.08"
[main ed1d509] 2024.04.08
2 files changed, 272 insertions(+), 2 deletions(-)
create mode 100644 effect/index.html
▶ git push -u origin main을 입력하여 github에 commit 파일 저장
1
2
3
4
5
6
7
8
9
10
11
12
C:\Users\line\Documents\GitHub\class2024>git push -u origin main
info: please complete authentication in your browser...
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 12 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 2.76 KiB | 2.76 MiB/s, done.
Total 6 (delta 3), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/HwangInJi/class2024.git
d72c9bd..ed1d509 main -> main
branch 'main' set up to track 'origin/main'.
▶ push 후 commit이 완료되면 해당 파일의 github code가 변경된 걸 확인할 수 있습니다.