다른 지점으로 전환하려면 어떻게 해야 합니까?
다음 중 어느 선이 맞습니까?
git checkout 'another_branch'
또는
git checkout origin 'another_branch'
또는
git checkout origin/'another_branch'
그리고 그들 사이의 차이점은 무엇입니까?
한다면another_branch이미 로컬에 존재하며 이 분기에 없습니다.git checkout another_branch분기로 전환합니다.
한다면another_branch하지 않지만 존하지않입니다.origin/another_branch 요래그,git checkout another_branch는 와동합다니등다에 합니다.git checkout -b another_branch origin/another_branch; git branch -u origin/another_branch그것은 창조하는 것입니다.another_branchorigin/another_branch 트세를 합니다.origin/another_branch의 로서.another_branch.
다 존재하지 않는다면, 둘다존않는면다지하,git checkout another_branch오류를 반환합니다.
git checkout origin another_branch대부분의 경우 오류를 반환합니다.한다면origin이고 는판이며개정▁is는이,며,another_branch파일인 경우 해당 수정본의 파일을 확인하지만 대부분 예상과 다를 수 있습니다. origin 에주로사용다니됩서에서 사용됩니다.git fetch,git pull그리고.git push원격 저장소에 대한 URL의 별칭입니다.
git checkout origin/another_branch성공하는 경우origin/another_branch아닌 상태로 .분기가 아닌 분리된 HEAD 상태로 이어집니다.새 커밋을 만들면 기존 분기에서 새 커밋에 연결할 수 없으며 분기가 업데이트되지 않습니다.
업데이트:
2.23.0이 출시되었기 때문에, 우리는 또한 그것과 함께 사용할 수 있습니다.git switch분기를 만들고 전환합니다.
한다면foo 전존시로 .foo:
git switch foo
한다면foo하지 않으며 존하지않다니습입니다.origin/foo 를 해 보십시오. 생성을 시도합니다.fooorigin/foo다음으로 전환합니다.foo:
git switch -c foo origin/foo
# or simply
git switch foo
더 일반적으로 더일적면 약에만.foo 를 생성해 . 생성해 보십시오.foo으로 전환합니다.foo:
git switch -c foo <ref>
git switch -c foo <commit>
에 두 수 를 들어, 만우과 Gitlab에 Github동시면저장, 로저는예들를어, 소컬두개수가있다습니질원저를, 약의소격장장리가다한지를소에유▁if▁have▁rem,otes▁two▁for다▁the,있니▁g수▁repos▁example▁maintain습▁g만▁may가▁at▁g▁in▁a약▁we두▁local질itory▁and개ititory리의원를에저▁repos,면,,소격우장▁glab가ith어과origin 및 Gitlab »githubGithub을 위하여.에는 " " " " "라는 이름이 있습니다.origin/foo그리고.github/foo.git switch foo불평할 입니다.fatal: invalid reference: foo ref, 어느기서온것알수지없인때문기에에준,▁ref,▁which때▁from▁it에문▁not▁because▁known▁does없기,origin/foo또는github/foo를 만들다foo을 로지해합니로 .git switch -c foo origin/foo또는git switch -c foo github/foo원격 둘 새 이 좋습니다.
git switch -c gitlab_foo origin/foo
git switch -c github_foo github/foo
한다면foo 만들기 만들기를 하십시오. 다시 만들기/강제로 만들기foo 재설정)foo한 후 합니다.foo:
git switch -C foo <ref>
git switch -C foo <commit>
다음과 같습니다.
git switch foo
git reset [<ref>|<commit>] --hard
알려진 ref 또는 commit의 분리된 HEAD로 전환해 봅니다.
git switch -d <ref>
git switch -d <commit>
분만생고전환않지다사다용니합음을면으려하성기하다▁if사니▁use를 사용합니다.git branch commit에서 해 보십시오.알려진 ref 또는 commit에서 분기를 생성해 보십시오.
git branch foo <ref>
git branch foo <commit>
다른 분기 git로 전환 중입니다.단도직입적인 대답,
git-checkout - 분기 전환 또는 작업 트리 파일 복원
git fetch origin <----this will fetch the branch
git checkout branch_name <--- Switching the branch
분기를 전환하기 전에 수정된 파일이 없는지 확인합니다. 이 경우 변경 내용을 커밋하거나 저장할 수 있습니다.
일상생활에서 사용할 수 있는 유용한 명령:
git checkout -b "branchname" -> creates new branch
git branch -> lists all branches
git checkout "branchname" -> switches to your branch
git push origin "branchname" -> Pushes to your branch
git add */filename -> Stages *(All files) or by given file name
git commit -m "commit message" -> Commits staged files
git push -> Pushes to your current branch
피쳐 분기에서 dev로 병합하려면 먼저 "git branch dev/develop" 명령을 사용하여 dev branch를 체크아웃한 다음 merge commandn "git merge feature branchname"을 입력합니다.
[git checkout "branch_name"]
또 다른 표현입니다.
[git checkout -b branch_name origin/branch_name]
"syslog_name"이(가) 원격으로만 존재하는 경우.
[git checkout -b branch_name origin/branch_name]는 여러 개의 리모컨이 있는 경우에 유용합니다.
[에 대하여git checkout origin 'another_branch'] 이것이 가능한지 확실하지 않습니다. AFAK는 "fetch" 명령을 사용하여 이 작업을 수행할 수 있습니다. -- [git fetch origin 'another_branch']
Git 2.23 이상에서는git switch <branch name>분기를 전환합니다.
저에게 효과가 있었던 것은 다음과 같습니다.
필요한 분기로 전환:
git checkout -b BranchName
그런 다음 "마스터"를 끌어 당겼습니다.
git pull origin master
확인:git branch -a
브랜치가 하나만 있는 경우.그런 다음 아래 단계를 수행합니다.
- 1단계:
git config --list - 2단계:
git config --unset remote.origin.fetch - 3단계:
git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
분기에 변경 사항을 적용하고 변경 사항을 끌어오는 등 매우 중요한 원격 분기를 분기가 추적하도록 하려면 다음을 추가해야 합니다.-t실제 을 할 : 실제체크의경다같음습다니과우웃아▁for다같니.git checkout -t branchname
나는 이것을 사용해서 당신이 사용할 수 있는 아무나 다른 브랜치로 바꿀 수 있습니다. 그것은 나에게 매력적으로 작용합니다.
git 스위치 [지점 이름] Orgit 체크아웃 [지점 이름]
: ORex : git 위치개발스▁or개 OR
checkout 크아웃개발체개발▁g.
변경 사항이 있는 분기로 전환하려면 먼저 가져오기를 수행해야 합니다.이것은 패키지와 같은 변경 사항을 저장하기 위한 것입니다.json 또는 .env 파일
그래서:
git fetch
그리고 나서:
git checkout <new branch>
이 대답은 저처럼 잠시 멈춰있던 사람들을 위한 것입니다.
명령 하나로 다른 분기 git로 전환할 수 있습니다.
git switch branch-name
원격 분기 목록 확인:
git branch -a
다른 분기로 전환:
git checkout -b <local branch name> <Remote branch name>
Example: git checkout -b Dev_8.4 remotes/gerrit/Dev_8.4
로컬 지점 목록 확인:
git branch
모두 업데이트:
git pull
다음 단계를 수행합니다.
- git 클론 {link}
- cd {repo folder}
다음을 사용하여 상태 및 현재 지점을 확인할 수 있습니다.
- git 상태
- 깃 가지
- git branch -a
참고: 여기서 새 지점으로 이동하기 전에 로컬 보고서를 변경하더라도 다음 단계는 계속 작동합니다.
"git branch"에 마스터가 표시되고 다른 branch로 + 이동하려면 다음을 수행합니다.
- git checkout -b {hostname}
"git branch"를 사용하여 branch를 다시 확인합니다. 이제 새 branch에 있다는 것이 표시됩니다.
이제 추가, 커밋 및 푸시:
- git add
- git commit -m "새 분기 추가"
- git push origin {hostname}
위의 단계는 제가 새로운 지역 지점으로 이동하기 전에 변경을 하거나 새로운 지점으로 이동한 후에 변경을 하는 상황 모두에서 저에게 효과가 있습니다.비슷한 상황에 처한 사람들에게 도움이 되고 여기에 언급된 질문에 대한 해결책이 되기를 바랍니다: 링크
언급URL : https://stackoverflow.com/questions/47630950/how-can-i-switch-to-another-branch-in-git
'programing' 카테고리의 다른 글
| MongoDB 및 Nodejs를 사용한 날짜 삽입 및 쿼리 (0) | 2023.05.25 |
|---|---|
| Bash에서 하위 문자열 추출 (0) | 2023.05.25 |
| C++ 표준::쌍의 C# 아날로그는 무엇입니까? (0) | 2023.05.25 |
| .NET 표준과 .NET 코어 비교 (0) | 2023.05.25 |
| Node.js에서 npm 모듈을 제거하려면 어떻게 해야 합니까? (0) | 2023.05.25 |