본문 바로가기

Remote repository / Branch 본문

BF 2024/Git

Remote repository / Branch

jaegomhoji 2022. 3. 30. 17:40

** Deafult Branch .. main ? or master?

> github의 default 는 Main > 즉 remote repository 를 만들면 main으로 생성된다 

> git의 default는 master > 즉 local 에서 repo 만들면 master로 생성된다 

> rename도 가능하고, 기본적으로 default branch 이름도 수정할 수 있다 ( 회사의 업무 명세서에 따른다 ). 

> view all branches > 하나의 Repository branch 이름 rename 

 

** Remote Repository 로컬에 복제하기

> Local Repository 를 생성하지 않은 상태에서, git clone 명령으로 remote repository를 local에 복제할 수 있다

> 쉽게 말해서 자료를 다운받아온다

 

** Git clone -> 밑의 3가지 단계를 한번에 수행한다 -> git clone https://username:token@github.com/repository.git 

1) git clone 으로 폴더 초기화 ( .git 생성 , 해당 폴더를 git이 관리하기 시작한다 )

2) remote repository 등록

3) remote repository 의 내용을 pull 한다  

 

> git clone 이후 ls로 local repository 생성 확인 , cd hellogit , ls -all 로 .git 파일 생성 확인 

 

** Branch 

** branch 조회 : git branch -> local repository 에 있는 것들만 조회된다 

 

** remote repository branch 조회 : git branch -r 

** remote + local branch 조회 : git branch -a

> 현재 local : main 과 remote : origin / HEAD and main 이 모두 확인된다 

 

** branch 생성하기 : git branch branchname

> 예제에서는 branch01 을 생성, 그러나 git branch로 확인한 결과 아직 main branch를 사용중 * 

 

** branch 이동하기 : git checkout branchname 

> 확인해본 결과 branch01 로 *이동함 

 

** branch 생성 + 이동하기 : git checkout -b branchname

 

** git push origin branchname 으로 git 서버에 branch 생성하기, 그리고 git branch -r , github 페이지에서 확인하기  

 

** branch 삭제하기 : git branch -d branchname 

> branch 에 머물러 있는 상태에서는 해당 branch를 삭제할 수 없다 

 

** remote repository 의 branch 삭제 : git push origin --delete branchname

> github 에서도 main 을 제외한 branch01 branch02가 삭제되었다. 

'BF 2024 > Git' 카테고리의 다른 글

Git tag ( 태깅, 상세 정보, push, 삭제 )  (0) 2022.03.31
Merge  (0) 2022.03.31
Log / Diff  (0) 2022.03.30
Remote Repository 생성  (0) 2022.03.29
Local Repository  (0) 2022.03.29
Comments