git init - 현재 디렉토리를 git 디렉토리로 만들겠다
git add 대상 - git이 파일을 추적하게만든다
git status - 프로젝트 폴더의 상태 확인
git config --global user.name "자신의 닉네임"
git config --global user.email "자신의 이메일"
-> 사용하는 사람에 대한 정보 설정이며
한번만 해주면된다
git commit 을 입력하게되면 내용이 나타나는데 그부분은 version을 나타내어 준다.
-> vim으로 동작
git log - version을 확인할수있다
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: f1.txt
no changes added to commit (use "git add" and/or "git commit -a")
modified
라고 나타나개 되면
바로 commit 할게 아니라 git add 파일이름으로 다시 add를 시켜줘야한다
git add - commit 대기상태(stage area으로 올라가는것)
git commit - version을 만들기위해 올리기는것
repostitory - commit이된것들이 저장되는 공간
git log를 치게되면 id가 있는데
git reset 버전id --hard(해당하는 버전ID로 돌아가기)
git revert 버전id(이런게 있다)
git commit -a 자동으로 수정한것을 git add
git commit -m 메세지를 바로적을수있게
git commit -am "11" 11이라는 메모로 변경한것을 add 시켜서 commit 시키게된다
(add를 한번도 안한 파일은 불가능)
git branch 브랜치 목록을 볼때
exp
"*"master -> 현재 사용중 브랜치
git branch 브랜치이름
-브랜치 생성
git branch -d 브랜치이름
-브랜치 삭제
git checkout 브랜치이름
-브랜치로 전환
git checkout -b 브랜치이름
-생성도 하고 전환까지 할 브랜치 이름
git log를 해서보면 알겠지만, branch를 만들었을때의 상태는 branch를 만든곳의 상태와 같다는것을 알수있다.
git log --branches --graph
git log --branches --graph
로그에 모든 브랜치 표시, 그래프표시, 한줄로 표시
git log --branches --graph --decorate --oneline
--GUI로는 Sourcetree 사용 괜찮다!
브랜치간에 비교할때
git log "비교할 브랜치 명 1".."비교할 브랜치 명 2"
브랜치 간 코드 비교
git diff "비교할 브랜치 명 1".."비교할 브랜치 명 2"
git clone https://github.com/git/git.git gitsrc(폴더)
-github에 있는 source code를 가져오기
git log --reverse
로그 거꾸로 보기
git checkout (commitid)
해당 commitid로 체크아웃 하기
-commitid로 branch 처럼 checkout을 할수가있다.