
Git을 설치하면 윈도우와 동등 위치에 리눅스를 설치해 준다. 그래서 리눅스가 하드웨어로 명령 내려준다.
CMD - > 윈도우 -> HW GIT BASH -> 리눅스 -> HW * 리눅스 프로그램에서 이름에 .이 있으면 숨김파일
1. git 사용자 이름과 이메일 설정
$ git config --global user.email "hyeonjeong.jang.0302@gmail.com" $ git config --global user.name "HyeonjeongJang"
2. 설정된 이름과 이메일 확인하기
$ git config --global --list user.name=HyeonjeongJang user.email=hyeonjeong.jang.0302@gmail.com
3. github에 파일 올리기
git init git add . git commit -m "프로젝트 초기화"
git init - 폴더에 .git이라는 숨김 파일이 생기는데 이 파일이 있어야 git을 사용할 수 있다.
git add . - .git이 들어있는 폴더의 모든 파일에 대한 형상이 저장된다.
git commit -m “commit메시지” - 어떤 commit인지 알 수 있는 메시지를 함께 적어준다.
git log로 commit된 내역을 확인할 수 있다.
$ git log commit 1449e094421dbde1761ff05dcee1cf1567a33af9 (HEAD -> master) Author: HyeonjeongJang <hyeonjeong.jang.0302@gmail.com> Date: Tue Dec 12 10:06:32 2023 +0900 프로젝트 초기화
git log를 종료하려면 command 창에 q를 입력하면 된다.
해쉬 Hash
임의의 난수 16진수
0 1 2 3 4 5 6 7 8 9 A(10) B(11) C(12) D(13) E(14) F(15) 10(16)
16진수 숫자 3 ⇒ 0x03
해쉬의 특징
1) 안녕을 다시 해쉬해도 동일한 난수가 만들어 짐.
2) 복호화가 안 됨(AB3F7D를 안녕으로 해석해주는 알고리즘이 없음, 그러나 그냥 사람이 저 글씨를 보고 “아! 저게 안녕이었지?” 할 수 있어) ⇒ 단방향(
ex) 안녕 → hash → AB3F7D ⇒ 임의의 난수가 만들어 짐.
그런데 해쉬를 왜 쓸까?!
무엇을 해쉬하든지 항상 동일한 길이가 나와.(안녕을 해쉬해도 책 한 권을 해쉬해도 똑같은 길이가 나옴)
무진기행(김승옥)의 해쉬와 무진기행(김승오)의 해쉬는 달라.
위조를 확인할 수 있어.(진위여부를 판단할 때 쓴다)
이것을 이용해서 전자서명을 할 수 있어!! 와우
git log를 했을 때 나오는 긴 문자열도 해쉬다.

해쉬를 이용하면 원하는 버전의 commit으로 되돌아갈 수 있다.
첫 번째 commit은 태양
두 번째 commit은 변수

첫 번째 commit(태양)상태로 돌아가는 방법
(556e는 태양 해쉬의 앞 4자리, 해쉬 전체를 다 적어줘도 된다.)
$ git reset --hard 556e
취소된 commit을 복구하는 방법
git reflog
.git 폴더를 삭제하고 싶을 경우
$rm -r .git
명령어를 입력하면 질문이 나오고 y+ enter를 계속 입력하면 파일이 삭제된다.

그냥 바로 삭제하고 싶다면 아래의 명령어를 입력하면 된다.
$rm -rf .git
-는 약어, --는 풀네임
github를 사용하려면 폴더와 github repository를 연결해야 한다.
git remote add origin [github repository주소] git remote add origin https://github.com/Hyeonjeong-JANG/java-lec-study.git
github repository 주소를 얻는 방법
1. github repository를 얻으려면 github에 가입해야 한다.
Github 가입하기(페이지 미완성) (1)2. repository 생성
New repository - Repository name 설정 - Public 체크 - Create Repository 클릭


3. repository 주소 복사

git이 github에 연결되었는지 확인하는 방법
$ git remote -v origin https://github.com/Hyeonjeong-JANG/java-lec-study.git (fetch) origin https://github.com/Hyeonjeong-JANG/java-lec-study.git (push)
github에 변경된 파일들을 올리는 것은 push라고 한다.
push 명령어는 다음과 같다.
$ git push origin master
강제 푸시
git push -f origin master
첫 번째 commit은 init 직후에 하자.
git init을 하면 파일에 여러가지 변경이 생기기 때문에 commit된 파일이 복잡하다.
commit을 할 때마다 변경된 내용만 보이기 때문에 그렇게 해야 무엇이 변경되었는지 보기 편하다.
(첫 번째 파일 commit 메시지에 init이라는 단어가 들어가면 좋을 듯)



디버깅
버그를 잡아가는 과정
거창하게 생각하지 않아도 된다.
아래의 명령어를 입력했을 때 오류가 생긴다면 그 오류의 원인이 무엇일까?
git --version
- git이 설치되지 있지 않다.
깃 설치 페이지 만들어서 연결하기(install안에)
- 환경 path가 설정되어 있지 않다.
자바 경로 설정을 응용해서 git의 환경 path경로를 설정할 수 있다.
이렇게 오류의 원인이 되는 경우의 수를 적어보고 하나씩 해결해 나가자!!
인터럽트(interrupt)를 하면 프로그램 실행을 멈출 수 있다.
ctrl + c
Share article