git config --global user.name "이름" # 유저 이름 설정
git config --global user.email "이메일" # 유저 이메일 설정(github 가입 시 이메일)
git config --list # 정보 확인
git init # 초기화, git 사용할 준비 (프로젝트 맨 처음에만 해야함)
git remote add origin <주소> # repository와 local 연결
git remote add upstream <주소> # fork 시 기존 repository와 local 연결
git remote -v # 연결 확인
git init
시 수정 이력들이 다 담기는 .git 폴더가 생김git add . # 모든 파일 add
git add <파일1> <파일2> # 파일(들) add
git status # 파일 변동 사항 보기
git commit -m "코드 수정사항 설명" # 히스토리 만들기
git push origin # github에 업로드(default: master branch)
git clone <주소> # repository명으로 된 폴더에 다운로드
git clone <주소> <폴더> # repository 파일들 <폴더>에 다운로드
git clone -b <브랜치명> <주소> <폴더> # <브랜치명> branch의 파일 <폴더>에 다운로드
cd <폴더> # 해당 폴더로 경로 이동
code . # vscode 실행
git add .
git commit -m "코드 수정사항 설명"
git branch <브랜치명> # branch 생성
git branch # branch 목록 확인
git checkout <브랜치명> # 해당 branch로 이동
git push origin <브랜치명> # branch에 push
git add .
git commit -m "백업"
git pull origin # 코드 수정 사항 받아옴
git push origin <브랜치명>
4.2. commit 로그 확인
git log # commit 로그 출력
git log -p # 각 commit의 diff 결과 보여줌
git log --stat # 각 commit의 통계 정보 조회
4.3. commit 취소
reset
사용revert
사용git reset HEAD^ # 바로 이전 commit 취소
git reset --hard <commit id> # 해당 commit으로 돌아감, 해당 commit 이후 commit은 삭제
git revert <commit id> # commit 삭제가 아닌 추가
참고
https://www.youtube.com/watch?v=Bd35Ze7-dIw
https://youtu.be/lelVripbt2M
https://youtu.be/cwC8t9dno2s
https://velog.io/@njs04210/Git-reset%EA%B3%BC-revert-%EC%95%8C%EA%B3%A0-%EC%82%AC%EC%9A%A9%ED%95%98%EA%B8%B0