230130 git 사용법

신동윤·2023년 1월 30일
0

명령줄에서 새 리포지토리를 생성합니다.

echo "# asd" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/zmtlzmtl/저장소.git
git push -u origin main

명령줄에서 기존 리포지토리를 푸시합니다.

git remote add origin https://github.com/zmtlzmtl/저장소.git
git branch -M main
git push -u origin main

저장소 변경하기

  1. 내 github에서 새 repository 생성 및 주소 복사

  2. 터미널에서 remote url 확인
    명령어 : git remote -v

  3. remote 주소 변경
    명령어 : git remote set -url origin "repository 주소"
    주소 변경뒤 다시 git remote -v로 확인하면 바뀌어 있음

  4. 프로젝트를 업로드 해준다

저장소 변경하기

  1. vscode에서 또는 putty나 터미널 환경에서 ssh로 서버에 접속합니다.

  2. 현재 브랜치 확인
    $ git branch

  3. 프로젝트 브랜치 목록 확인하기
    $ git branch -a

  4. 브랜치 목록 중에서 바꿀 브랜치 풀경로로 복사

  5. 브랜치 변경
    git branch -t 바꿀 브랜치 풀경로
    -t는 브랜치를 받는 로컬쪽에 branch이름과 동일하게 branch를 생성하고 동시에 checkout합니다.

  1. 브랜치 변경 확인
    git branch
  1. 업데이트된 소스를 서버로 git pull로 내려받기
    git pull

0개의 댓글