다디와 괴발개발

[Github] git에서 특정 브랜치만 clone하는 방법 본문

TroubleShooting

[Github] git에서 특정 브랜치만 clone하는 방법

아임다디 2022. 5. 8. 22:51

상황


Git clone을 하고싶은데 main이 아닌 다른 특정 브랜치를 clone 해오고싶어서 방법을 찾아봤다.
그냥 Git clone을 진행하면 main 브랜치가 클론되는데, 내가 clone해오고 싶은 브랜치는 master인 상황이었다.

해결


git clone -b 'branch name' --single-branch 'repository url'
git clone -b master --single-branch 'repo url'

이렇게하면 master의 branch 내용만 클론 해올 수 있다