Git 사용

wanni kim·2021년 4월 15일
0

fork한 파일
git clone forkurl
git status //변경상황 확인하기
git add index.js // unstaged -> staged
git commit index.js //커밋하기
git commit -m "index.js 수정" //커밋에 메모하기
git reset HEAD^ //commit한 자료 취소하기

https://gmlwjd9405.github.io/2018/05/25/git-add-cancle.html

local의 파일을 staging area로 옮길때
git add index.js
git add ./index.js
git add .
git add *

git reset HEAD^
git reset HEAD~1
git reset HEAD^1

git push origin main
git push

git log //commit log확인

git init // directory를 git의 관리하로 설정하기 위한 명령어

gir remote add origin url //origin이라는 이름으로 내 리모트 레포지토리에 등록

git remote -v
git remote --verbose //remote에 잘 연결 되었는지 확인

git pull pair main //페어의 remote repository에 연결된걸 확인했으면 내 local로 땡겨온다.

git push origin main //페어가 내가 지금 커밋하려는 파일보다 이전 버전에서 작업을 했더라도 내가 작업한 커밋과 merge(병합)이 자동으로 된다.
이제 내가 나의 remote repository로 push하면 끝.

git add *
git add .
git add ./footer.html
git add footer.html //내가 수정한 footer.html 파일을 다시 푸쉬하기위해서는 untracked area에서 staging area로 add 해줘야한다.

git commit -m "footer 수정" // staging area로 넘어간 footer.html을 메모와 함께 commit한다. 그렇게 되면 나의 remote local repository로 들어가게 된다.

git pull pair main // 페어도 footer.html을 수정했다고 하면, 페어의 파일을 나의 local repository로 pull 해온뒤에 자동 merge 된다. 하지만 만약 같은 줄을 고쳤다면 충돌이 일어나게 되고 그것을 해결해야한다. 만약 충돌이 생긴 라인을 알고 수정한뒤에 다시 untracked area에서 staging area로 add하고 local repository로 commit하여 나의 remote repository로 푸쉬하면 된다.


위 그림과 같이 충돌이 해결된 후 자동으로 commit 메세지가 생성된다고 하는데 자동 생성된 커밋 메세지가 무엇인지는 실습을 통해 알아가야 할 것 같다. 그래도 어쨋든 git commit을 명령해야한다.

커밋이 완료되면 -m "블라블라" 로 입력되는 메세지가 "merge commit"으로 자동으로 적힌다는 말이였다.
그리고 local repository에 있는 최종 파일을 나의 remote repository로 올리면 당연히 git push origin main. -끝-.

profile
Move for myself not for the others

0개의 댓글