Git
[Git] git 프로젝트
qoth_0
2023. 12. 6. 18:15
728x90
반응형
반응형
git 프로젝트 생성 및 수정절차
방법 1. 신규 프로젝트 생성시
- git clone ropository 주소
- 해당 폴더로 이동하여 개발시작
방법 2. 로컬 컴퓨터에서부터 이미 개발된 프로젝트가 존재 시
- git init
- .git파일 생성
- .git 폴더가 위치한 곳에서 git config —list를통해 config 정보 조회
- git remote add origin [repository 주소] : 오리진 추가
- 비어있는 repository주소를 채우는 명령어
- origin이란, 깃허브 저장소 주소를 의미(즉, 원격저장소를 의미)
- git remote set-url origin : 오리진 변경
- repo url변경 하는 명령어
- url 변경 후 main에 push하면 main의 commit 이력과 함께 업로드
- git remote remove origin : 오리진 삭제
- 모든 이력 push
- git push —all
- 모든 브랜치의 커밋이력 push
- git push —all
실습
- spring initializer 패키지 다운받아서 방법 2로 올려보기
- gradle-groovy/java/3.1.6/Jar/17 선택

add dependency - spring web 선택

generate

다운로드된 zip파일 압축해제하고 vs코드에서 open folder

git init

.git폴더 생성됨
github에 빈레포 만들기

주소카피
git remote adgd origin 해당 주소
git checkout -b main : main branch를 만들면서 이동해주는 명령(master 그대로 카피해서 옮김)

master에서 커밋 후 푸쉬 전 master에서 main 브랜치로 바꿈
→ checkout 시 직전의 branch의 내용을 카피해서 이동하게 됨

업로드 확인
실습2
- 강사님의 public repository를 clone하되 기존의 commit이력없이 본인의 repository로 업로드
- 클론받고 내꺼처럼 하고싶을 때
- 방법1. set-url origin
- 방법2. remove origin 후 add origin 하면 됨
- .git폴더에 커밋이력이 있으므로 삭제 하면 됨
- 클론받고 내꺼처럼 하고싶을 때
실습3
728x90
반응형