Posts [HTML/CSS] Git 기본기 연습
Post
Cancel

[HTML/CSS] Git 기본기 연습

screenshot115

Git Branch 생성하고, 확인하기


In Git, branches are a part of your everyday development process.

Git branches are effectively a pointer to a snapshot of your changes.

Git Branch 생성

raccoon 이라는 이름의 branch 생성

1
$ git branch raccoon

Git Branch 목록 확인

Local Branch 목록 확인

1
2
$ git branch
$ git branch --list

Remote Branch 목록까지 확인

1
$ git branch -a

Brach Checkout (브랜치 이동)

Branch 생성하면서 생성된 branch로 checkout

1
$ git checkout -b ex-raccoon  # Switched to a new branch 'ex-raccoon'

main branch로 checkout

1
2
3
$ git checkout main
# Switched to branch 'main'
# Your branch is up to date with 'origin/main'.

Git Clone(원격지 repo를 local로 복사)

screenshot117

1
2
3
4
5
6
7
$ git clone https://github.com/juddroid/fe.git
# Cloning into 'fe'...
# remote: Enumerating objects: 3, done.
# remote: Counting objects: 100% (3/3), done.
# remote: Compressing objects: 100% (2/2), done.
# remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
# Unpacking objects: 100% (3/3), 631 bytes | 63.00 KiB/s, done.

하지만 이렇게 clone 하면 모두의 branch 를 다 가져오게 된다.

screenshot118

여기에서 몇 가지 실험…

  1. clone 할 때, 주소 마지막에 .git 이 필요한가?

    .git 유무에 상관없이 잘 clone 됐다.

  2. 아래와 같이 clone 하면 어떻게 될까?

    1
    
    $ git clone -b raccoon --single-branch https://github.com/juddroid/fe.git
    

    raccoon 이라는 branchcheckout 되면서 clone

  3. 브랜치 옵션을 삭제하고, --single-branch 옵션만 남겨두면 어떻게 될까?

    1
    2
    3
    4
    5
    
    $ git clone --single-branch https://github.com/juddroid/fe.git
    # * main
    #  remotes/origin/HEAD -> origin/main
    #  remotes/origin/main
    # (END)
    

    그냥 main 브랜치로 clone 해온다.

Git Branch 삭제하기

ex-raccoon 브랜치 삭제

1
$ git branch -d ex-raccoon  # Deleted branch ex-raccoon (was ef47882).

정리

어느 순간부터 gitCLI 연습해보기 위해서 GUI 를 사용하지 않고 있다. 간단하게 commit, push 같은 작업만하고, 혼자서만 작업을 하니 크게 불편함이 없었다. 이제 조금씩 미뤄뒀던 다른 명령어들과 HEADrebase 등 너무 헷갈리는 개념들에 대해서 한 번 제대로 이해를 해봐야겠다.

참조

  • https://www.atlassian.com/git/tutorials/using-branches/git-checkout
This post is licensed under CC BY 4.0 by the author.

[thinkAbout] 새벽감성으로 생각정리하기

[Digging] 어쩌다보니 Node debugging 환경 세팅

Comments powered by Disqus.