기타/Useful tool
[Git] Git 설치 및 사용법 (Git Bash 사용하기)
미래미래로
2020. 6. 30. 23:06
728x90
git config
Git 설정하기
- Commit에 사용할 user name과 email 설정하기
- 최초 1회 실행
// git commit에 사용될 username
git config --global user.name "your_name"
// git commit에 사용될 email
git config --global user.email "your_email@example.com"
// 설정 내용 확인
git config --list
git init
로컬 저장소로 설정하기
// 로컬저장소로 설정할 프로젝트 위치로 이동
cd "프로젝트 위치"
// 로컬저장소로 설정
git init
// init 취소
rm -r .git
git status
로컬 저장소의 현재 상태 확인하기
// 로컬저장소의 현재 상태
git status
git add
파일을 준비영역(Staging Area)으로 옮기기
// index.html 파일만 추가
git add index.html
// 디렉토리 내 모든 파일을 추가
git add .
git commit
Staging Area의 파일을 로컬저장소에 저장
// 에디터가 출력되고, 에디터에서 commit message 입력 후 저장하면 commit완료
git commit
// 간단한 commit message를 입력후 commit완료
git commit -m "commit message"
// Staging Area에 들어간 파일에 대해서만 (워킹 디렉터리는 적용 X)
git commit -a -m "commit message"
git log
로컬저장소의 commit 이력 조회
// commit list 조회
git log
// commit list 중 커밋ID, 타이틀 메시지만 조회
git log --oneline
// 모든 브랜치 commit 이력 조회
git log --oneline --decorate --graph --all
// 특정 파일의 변경 commit 조회
git log -- a.html
git remote
로컬저장소와 원격저장소를 연결
// Github 원격저장소와 연결
git remote add origin [자신의 Github 원격저장소 주소]
// 연결된 원격저장소 확인
git remote -v
로그인을 하지 않았다면, 위와 같은 로그인 페이지가 뜨고, 로그인을 해주어야 한다.
성공하면 아래와 같은 결과창이 뜬다.
git push
원격저장소에 저장
// 원격저장소에 저장
git push -u origin master
728x90