카테고리 없음

자주쓰는 Git 명령어

kk_eezz 2022. 4. 26. 21:23

 

1. Github 연결

 

cd 명령어로 프로젝트가 있는 파일로 이동

git remote add [origin] [github 주소]

나는 이미 연결해놓은 상태라서 origin already exists 라고 뜬다.

깃헙주소는 다음과 같이 Code 버튼을 누르면 복사할 수 있게 되어있다.

git remote 명령어로 확인해볼 수 있다.

git remote

 

 

2. Github에 커밋하기

 

git add .
git commit - m "커밋 메시지를 여기에다가 작성"
git push

 

3. branch 생성하기

git branch <branchname>

 

4. branch 목록 보기

git branch

 

5. branch 변경하기

git checkout master

 

6. 원격 저장소 삭제하기

git remote rm <origin>

 

7. git revert 취소하기/전 작업으로 돌아가기

 

작업된 로그 확인

git reflog

전 로그로 돌아가기

git reset --hard [로그번호]

강제 푸쉬

git push -f origin master