Post

깃헙 셋팅 및 여러가지 기능

Github 편하게 써보자!

Git은 소스 코드 버전 관리 시스템(VCS, Version Control System) 중 하나로, 소프트웨어 개발에서 코드의 변경 이력을 효과적으로 관리 할 수 있게 해주는 도구입니다. Git을 사용하면 여러 개발자들이 동시에 작업하고 있는 프로젝트에서 발생하는 코드의 수정, 추가, 삭제 등의 변경 사항을 효율적으로 추적하고 관리 할 수 있습니다.


터미널에서 github 버전 확인하기

터미널을 열어서 버전을 확인 하고 없으면 설치해야 합니다.

1
2
3
git --version
git version 2.39.3 (Apple Git-146)
nicejmp@bagjeongmin-ui-MacBookAir ~ % 


설치가 완료되었다고 가정하고 버전을 확인 했을때 특이 점이 없으면 이제 사용자의 name과 email이 일치한지 확인해야합니다.

확인 하는 방법으로 git config –list 으로 입력한 후 확인합니다.

1
2
3
4
5
6
7
8
9
nicejmp@bagjeongmin-ui-MacBookAir ~ % git config --list
credential.helper=osxkeychain
init.defaultbranch=main
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=박정민
user.email=a01063363854@gmail.com


만약 본인의 이름과 이메일이 아니라면 변경을 해야 합니다. 변경 방법으로 아래와 같이 진행 하면 됩니다.

해당 코드를 사용하여 name과 email을 변경하도록 합니다.

git config –global user.name “이름” git config –global user.email “이메일”


1
2
git config --global user.name "이름"
git config --global user.email "이메일"


그 이후 documents 안에있는 github 폴더로 이동합니다. ls -a로 숨김파일을 찾은 후 .git 폴더가 있는지 확인 합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
ls -a 로 숨김파일을 찾습니다.

nicejmp@bagjeongmin-ui-MacBookAir class2024 % ls -a
.		.gitignore	index.html	quiz		test3.html
..		README.md	javascript	test		webd
.DS_Store	assets		json		test1.html
.git		effect		mysql		test2.html
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
nicejmp@bagjeongmin-ui-MacBookAir class2024 % 

git의 상태를 확인하기 위해 git status (상태확인)를 입력 후 커밋할게 있는지 확인합니다.

1
2
3
4
5
6
7
nicejmp@bagjeongmin-ui-MacBookAir 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)
	modified:   effect/index.html


👍 Git 터미널로 commit 하기

commit 하는 파일을 확인 후 해당 명령어를 입력하면 된다.

Commit 하기전 주의사항

맥 같은 경우 토큰을 생성 해야한다. 귀찮더라도 꼭 설정해야 작동이 되니 필수로 해야한다. 깃헙 홈페이지로 들어가 Settings 해야한다.

image 10

Settings에 들어간 후
image 11

Developer settings으로 들어간다.
image 12

그 후 Personal access tokens에서 Fine-grained tokens를 들어간다.

image 13

마지막으로 Token name을 입력 후 생성버튼을 클릭하게 되면 토큰이 생성되게 된다. 그 토큰을 메모장에다가 잘 적어두도록 합시다.

토큰이 생성되고 난 후 이제 본격적으로 터미널을 이용한 commit작업을 할텐데 해당 명령어대로 진행 하면 commit이 되는것을 확인할 수 있을것이다.

1
2
3
4
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git commit -m "2024.04.08"
[main c3bf485] 2024.04.08
 1 file changed, 1 deletion(-)

git commit -m “커밋할 내용의 제목” 을 입력하게되면 위에 사진처럼 나올텐데 이러면 push 할 준비가 된것이다.

이제 push를 이용해 commit을 끝내보자.

1
2
3
4
5
6
7
8
9
10
11
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git push -u origin main
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 344 bytes | 344.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/nicejmp1/class2024.git
   b4f2f98..c3bf485  main -> main
branch 'main' set up to track 'origin/main'.

이런식으로 나오면 정상적으로 깃헙 서버에 commit이 된걸 확인 할 수 있다!! 🎉🎉

앞으로도 commit할 일이 생기면 이렇게 하면 된다.

추가로 vscode에서 커밋 할 수 있는 방법을 알려드리겠습니다.

위에서 설명한 명령어를 vscode 터미널에다가 입력해 준다면 아래와 같이 나오면서 commit과 push가 정상적으로 된것을 확인하게 될겁니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git add .
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git pull
Already up to date.
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git commit -m "2024.04.08"
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
nicejmp@bagjeongmin-ui-MacBookAir class2024 % git push -u origin main
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 515 bytes | 515.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/nicejmp1/class2024.git
   936d6ec..8177202  main -> main

🥲 Github 터미널로 사용해본 후기

생각보다 복잡하고 사용하는데 어려움을 느꼇지만 몇번이고 사용하게 되면 편해지겠지..? 이로써 개발자에 한걸음 다가간 기분이다.. 기분만 좋으면 됬지 머!


다음시간에 계속!

image

This post is licensed under CC BY 4.0 by the author.