티스토리 뷰
로컬 저장소
브랜치 이름 변경
git branch -m [OLD_BRANCH] [NEW_BRANCH]
이미 존재하는 파일 PUSH
cd existing_folder
git init --initial-branch=main
git remote add origin <저장소 url>
git add .
git commit -m "Initial commit"
git push -u origin main
push 할 때 에러메세지 [rejected] main -> main (non-fast-forward)
git pull origin main --allow-unrelated-histories
git push --set-upstream origin main
Branch 전환하기
1. git repository에서 새로운 Branch 생성(develop)
2. 생성한 브랜치를 pc에 내려받기
git pull origin develop --allow-unrelated-histories
3. pc에 새로운 브래치 생성후 브랜치 전환
git branch develop
git checkout develop
# 이 두 개의 명령어를 하나로 합치면 git checkout -b <branch>
4.push
git add test
git commit -m "branch test"
git push -u origin develop
Branch 삭제
Local
git branch -d [브랜치명]
Remote
git push origin --delete [브랜치명]