반응형
Git에서 파일 하나만 풀 수 있습니까?
저는 일부 고장난 테스트가 있는 Git 브랜치에서 작업 중이며, 이미 수정된 다른 브랜치에서 이러한 테스트를 끌어내고 싶습니다.
할 수 있다는 것을 압니다
git pull origin that_other_branch
하지만 아직 준비가 되지 않았기 때문에 많은 다른 파일을 병합하려고 합니다.
해당 다른 분기에서 지정된 파일(모든 파일은 아님)만 풀하고 병합할 수 있습니까?
이 질문에 대한 모든 대답은 분기를 변경하지 않고 로컬로 변경된 파일을 리포지토리 버전으로 되돌리는 방법이기 때문에 이는 하나의 파일에 대한 Git 풀 요청의 중복이 아닙니다.
제가 이것을 조사할 때 생각해낸 조금 더 쉬운 방법이 있습니다.
git fetch {remote}
git checkout FETCH_HEAD -- {file}
다음과 같은 방법으로 하나의 파일만 가져온 다음 체크아웃할 수 있습니다.
git fetch
git checkout -m <revision> <yourfilepath>
git add <yourfilepath>
git commit
에 대해서는git checkout
명령:
<revision>
지점 이름, 즉.origin/master
<yourfilepath>
저장소 이름이 포함되어 있지 않습니다(클릭 시 얻을 수 있음).copy path
GitHub의 파일 페이지에 있는 버튼, 즉README.md
git checkout master -- myplugin.js
마스터 = 지점 이름
myplugin.js = 파일 이름
@Mawardy의 대답은 나에게 효과가 있었지만, 나의 변경 사항이 리모컨에 있어서 나는 원산지를 지정해야 했습니다.
git checkout origin/master -- {filename}
로컬 파일을 다른 보고서 또는 분기의 파일로 덮어쓰려면 다음 명령을 사용합니다.
git checkout remoteName/branchName filePath
여기 제가 이전에 사용했던 예가 있습니다.
git checkout origin/master package-lock.json
예, 프로세스는 다음과 같습니다.
# Navigate to a directory and initiate a local repository
git init
# Add remote repository to be tracked for changes:
git remote add origin https://github.com/username/repository_name.git
# Track all changes made on above remote repository
# This will show files on remote repository not available on local repository
git fetch
# Add file present in staging area for checkout
git check origin/master -m /path/to/file
# NOTE: /path/to/file is a relative path from repository_name
git add /path/to/file
# Verify track of file(s) being committed to local repository
git status
# Commit to local repository
git commit -m "commit message"
# You may perform a final check of the staging area again with git status
언급URL : https://stackoverflow.com/questions/16230838/is-it-possible-to-pull-just-one-file-in-git
반응형
'programing' 카테고리의 다른 글
속성의 최종 목록 나열 - Spring Cloud Config Server (0) | 2023.07.01 |
---|---|
VBA를 사용하여 Excel 2007에서 셀을 투명하게 만드는 방법 (0) | 2023.07.01 |
원시 유형을 확장하는 TypeScript에서 공칭 유형을 만드는 방법이 있습니까? (0) | 2023.07.01 |
트리 계층 구조를 가져오기 위한 CTE 재귀 (0) | 2023.07.01 |
Spring Bean을 다시 초기화하는 방법은 무엇입니까? (0) | 2023.07.01 |