2020-10-21 22:10:36
Git 저장소 생성. 실행시 저장소 구성을 위한 .git 폴더가 생성된다.
$ git remote add origin https://github.com/jcwooo/ggb‘origin’은 원격 저장소를 가르키는 별칭이다.
현재 연결되어 있는 원격 repository 확인.
원격 repository 연결 끊기.
현재 저장소 파일들의 상태를 확인한다. 파일을 수정하였다면 위 명령으로 확인할 수 있다.
$ 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: src/html.jssrc/html.js 파일이 수정되었음을 확인할 수 있다.
git status로 수정 파일을 저장소로 반영하기 위해선 인덱스에 파일을 추가해야한다.
Git Repository 구조는 ‘작업폴더(Working Directory) > 인덱스(Staging Area) > 저장소(Head Repository)로 구성된다.
git add 명령은 저장소에 commit 하기 위해 추가 및 수정 파일을 인덱스에 기록한다.
$ git add src/html.js인덱스(Staging Area)에 올린 변경사항을 Head에 적용한다.
$ git commit -m "html 변경"변경 내용을 원격 저장소로 보낸다.
$ git push origin mastergit 저장소를 복사한다.
$ git clone https://github.com/jcwooo/sourcesource 디렉토리를 생성하고 저장소의 데이터를 모두 복사한다.
디렉토리 명을 변경하고 싶으면 아래와 같이 clone해주면 된다.
아래 명령어 실행시 ‘new-name’이란 디렉토리 하위에 데이터가 복사 된다.
$ git clone https://github.com/jcwooo/source new-namebranch를 생성한다. 아래 코드 실행시 ‘branch1’이란 branch가 생성 된다.
$ git branch branch1branch 생성 후 이동.
$ git checkout -b [branch1]$ git add [file name]
$ git commit -m "commit message"
$ git push origin [branch name]$ git checkout master // 1. master로 전환
$ git merge [branch name] $ git branch -d [branch name]