git, gitHub 정보 CLI
git 관련정보
Repository계정정보와 토큰을 캐쉬에 넣고 자동로그인 하기.(시간제한 없음)
- 매번 계정과 토큰 넣기 불편하기 때문에 해당 정보를 캐쉬에 넣고 자동으로 사용한다.
$ git clone [Repository url]
Repository계정정보와 토큰을 캐쉬에 넣고 자동로그인 하기.(시간제한 있음)
- 매번 계정과 토큰 넣기 불편하기 때문에 해당 정보를 캐쉬에 넣고 자동으로 사용한다. timeout에 들어가는 단위는 초이다.
$ git config --global credential.helper 'cache --timeout=[SECOND]'
- 매번 계정과 토큰 넣기 불편하기 때문에 해당 정보를 캐쉬에 넣고 자동으로 사용한다. timeout에 들어가는 단위는 초이다. (7일)
$ git config --global credential.helper 'cache --timeout=604800'
Repository계정정보와 토큰을 git directory이외에 모든 git활동에 정보를 저장.(무제한)
- 위의 캐시방식에 비해 무제한적으로 사용할수 있다.
$ git config credential.helper store --global
토큰이 만료되고 새로운 토큰을 주입할때
- 해당 remote-url(origin)을 삭제한다.
$ git remote remove origin
- remote-url을 삭제한 다음 새로 생성하는데 이때 Nickname과 Token을 갖이 입력한다.
$ git remote add origin https://Nickname:Token@github.com/repository path
Repository에서 프로젝트 클론(branch)
$ git clone -b [branch name] [Repository url]
Repository에서 프로젝트 클론(master)
$ git clone [Repository url]
Repository에서 프로젝트 클론(branch)
$ git clone -b [branch name] [Repository url]
git pull(GitHub에서 코드 업데이트)
$ git pull [repository 주소 or 이름 또는 origin] [branch 이름]
git add .(모든 변경 사항에 대해서 add)
$ git add .
add한 파일에 대해서 취소하기(관련링크)
$ git reset
--------------------------------------------------- reset options(click)
git commit 이전으로 되돌리기(Staging 변화 없음)
$ git reset HEAD~1 --soft
git commit 이전으로 되돌리기(이전상태로 완전 원복. 복구불가)
$ git reset HEAD~1 --hard
git commit을 commitId로 되돌리기 (뒤에 --soft, --hard는 동일하게 동작)
$ git reset [commitId]
git add (변경 사항에 대해서 선택적 add)
$ git add [파일 or 폴더 이름]
-----------------------------------------------------------------------------------------
git commit 하기(add한 파일, 폴더에 대해서 local로 commit하기)
$ git commit -m [commit 이름]
git status(git 상태확인)
$ git status
stash 임시저장하기
$ git stash
stash으로 임시 저장된 리스트 보기
$ git stash list
stash를 저장할때 주석 달기
$ git stash push -m [String : 주석내용(쌍따옴표)]
stash를 적용하기
$ git stash apply [list에 있는 번호]
stash를 적용하면서 해당 stash를 삭제. 아래 커멘드 실행 이후 해당 stash는 삭제
$ git stash pop [list에 있는 번호]
변경내역 확인하기
$ git reflog
이후에 "git reset --hard [해당 reflog ID]"를 실행하면 해당 지점으로 복원
참고 블로그 : git commit 또는 branch를 실수로 지우고 다시 복원해야 할때
git에 존재하는 branch 확인하기
$ git branch
branch 전환
$ git checkout [branch 이름]
branch 생성 및 이동
$ git checkout -b [branch 이름]
branch 삭제(다른 branch로 이동하고 나서야 가능함)
$ git branch -D [branch 이름]
git branch을 Fast Forward로 merge한다. (default가 Fast Forward이다.)
$ git merge [branch 이름]
git branch을 Recursive(ort)로 merge한다.
$ git merge --no-ff [branch 이름]
git branch을 Squash한다. commit 이전단계 인 stage단계이다. commit까지 진행해야 완료된다.
$ git merge --squash [branch 이름]
관련 설명 링크 : git commit 또는 branch를 실수로 지우고 다시 복원해야 할때(reflog)
해당 repository의 git를 초기화 한다.
$ git init
해당 repository의 github를 remote로 네이밍한다.
pull 또는 push할때 해당 네이밍을 사용할수 있도록 설정한다.
$ git remote add [네이밍] [url]
git의 remote를 확인한다.
해당 git의 remote가 어디로 지정됬는지 확인한다.
$ git remote
git의 remote url을 확인한다.
해당 git의 remote의 지정된 url을 출력한다.
$ git remote -v
git의 remote url을 초기화
해당 git의 remote의 지정된 url초기화 하여 다른 url로 add가 가능하게 해준다.
(fatal: remote origin already exists. 에러가 뜬다면 원래있던 remote를 삭제하고 다시 add시켜준다.)
$ git remote rm origin
해당 git의 log를 확인한다.
git log를 확인할수 있다.
$ git log
해당 git의 log를 graph으로 확인한다.
그래픽으로 git log를 확인할수 있다.
$ git log --graph --decorate
gitHub 관련정보
해당 repository에 존재하는 branch를 github를 통해 remote로 끌고온다.
GitHub에 브렌치를 끌고 온다. (링크참조)
$ git checkout [GitHub Remote]/[GitHub Branch] -b [Create Branch]
댓글
댓글 쓰기