시그마 삽질==six 시그마

git branch/checkout 본문

프로그래밍/GIT

git branch/checkout

Ethan Matthew Hunt 2020. 8. 10. 20:01

 

1. branch

 

#show local branches
git branch

#show remote branches
git branch -r

#List all branches(include remote)
git branch -a

#Delete the specified branch
git branch -d <branch>

#Force delete the specified local branch
git branch -D <branch>
ex) git branch -D feature/test2

#Force delete the specified remote branch

git push <remote_name> --delete <branch_name>
ex) git push origin --delete feature/test2


#Rename the current branch to <branch>.
git branch -m <branch>

https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely

 

 

2.  checkout

 

#Switching Branches
git checkout <branchname>


#creates and checks out <new-branch>
#base:the current HEAD
# -b argument that acts as a convenience method which will create the new branch and immediately switch to it
git checkout -b <new-branch>
git checkout -b feature/yyy
feature라는 폴더속에 yyy 브랜치 생성됨

#creates and checks out <new-branch>
#base:existing-branch
git checkout -b <new-branch> <existing-branch>



#Checkout a Remote Branch
In modern versions of Git, you can then checkout the remote branch like a local branch.
remote에 있던 branch가 로컬에 새로 들어옴+checkout.

git fetch --all 
git checkout <remotebranch> 

ex) git checkout feature/test(o) 
git checkout origin/feature/test (x)



 

source:

 

https://www.atlassian.com/git/tutorials/using-branches/git-checkout

 

Git Checkout | Atlassian Git Tutorial

Git branching intro. Create, list, rename, delete branches with git branch. git checkout: select which line of development you want and navigate branches

www.atlassian.com

 

'프로그래밍 > GIT' 카테고리의 다른 글

git repository 복사하기  (0) 2020.08.12
git 히스토리 초기화  (0) 2020.08.10
현재 브랜치를 마스터로 만들기  (0) 2020.03.06
이미 tracking된 원격 저장소에 .gitignore 적용  (0) 2020.03.06
Git Reset/ Revert  (0) 2020.03.06
Comments