Be Coder
Git bash 사용 본문
참고 : https://rogerdudler.github.io/git-guide/index.ko.html
https://git-scm.com/book/ko/v2
- 깃의 작업 순서
1. 작업
2. 커밋
3. 푸시
작업을 하고, 어떤걸 했는지 커밋하고, 소스코드를 푸쉬하는 방식.
1. Repository 프로젝트 가져오기(Clone repository)
- git clone /로컬/저장소/경로
- git clone 사용자명@호스트:/원격/저장소/경로
- git clone https://github.com/사용자/저장소
위의 경로 뒤에 Destination path도 지정할 수 있음.
Destination path 지정 안하면 현재 경로에 repository 이름으로 프로젝트 폴더가 생성됨.
2. 추가하기(add)
작업을 하고, 해당 파일이나 폴더를 사용자가 결정한다.
이 과정으로 해당 파일을 tracking하고, Stage에 올린다.
- git add <파일이름>
- git add *
git add에도 다양한 모드가 있음.
1. git add -A : 현재 경로의 모든 파일을 Stage에 올림.
2. git add -i : Interactive mode로 Stage에 올림.
3. git add -u : tracking 중인 모든 수정된 파일 stage에 올리기
3. 푸시
우선, 로컬 repository 에 커밋 (Commit into local repository)
- git commit
- git commit -m “이거 바꿈”
-m "메시지"로 커밋할 때, 한번에 기록까지 남기기.
다음, 원격 repository에 커밋 (Commit into remote repository)
- git push
번외.
1. 원격 저장소 계정정보 저장하기 (Save remote repository credential information)
: 1회 Push 이후에 따로 username, password 입력이 필요 없어짐
● git config credential.helper store
● git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>
2. 현재 Git Repository 상태 조회 (Look up current git repository status)
● git status
Stage에 올린 모든 파일 Unstage 하기 (Un-stage all staged files)
● git reset
현재 local change 모두 강제 리셋
● git reset --hard
현재 브랜치의 특정 커밋에 대한 변경사항 강제 리셋
● git reset --hard {commit_sha}
최근 1회의 커밋에 대한 강제 리셋
$> git reset --hard HEAD~1
커밋된 특정 파일 해제하기 (Un-commit file)
$> git rm {FILE_NAME}
특정 파일 tracking 영구 해제하기 (Un-track file)
$> git rm --cached {FILE_NAME}
특정 파일을 로컬 repo에 있는 파일에서 가져오기 (Checkout the file from local repository)
● rm 파일이름
● mv 파일이름, 파일이름2
먼저 해당 파일명을 바꾸거나, 삭제 해 주어야 한다.
● git checkout 파일 이름
나머지는 참고 링크랑 Pro Git책 봐야될듯.