Skip to content

cherrypick

지정된 커밋을 HEAD에 체리픽하고 워킹 트리와 인덱스를 업데이트해요. 이 메서드는 커밋이 적용된 것처럼 인덱스와 트리를 준비하지만, 실제로 새 커밋을 만들지는 않아요.

시그니처

ts
class Repository {
  cherrypick(
    commit: Commit,
    options?: CherrypickOptions | undefined | null,
  ): void;
}

파라미터

  • commit필수 · Commit

    체리픽할 커밋

  • optionsnull | CherrypickOptions

    체리픽 작업을 위한 옵션

    • checkoutOptionsCheckoutOptions

      워킹 디렉터리를 업데이트할 때의 체크아웃 동작을 위한 옵션

      • allowConflictsboolean

        안전 모드에서 충돌이 있더라도 체크아웃을 취소하는 대신 안전한 파일 업데이트를 적용할지 여부. 기본값은 false

      • ancestorLabelstring

        충돌에서 공통 조상(ancestor) 쪽의 이름

      • conflictStyleDiff3boolean

        충돌에 대해 diff3 형식 파일에 공통 조상 데이터를 포함할지 여부. 기본값은 false

      • conflictStyleMergeboolean

        충돌에 대해 일반 병합(merge) 파일을 작성할지 여부. 기본값은 false

      • dirPermnumber

        새 디렉터리를 만들 때 사용할 모드. 기본값은 0755

      • disableFiltersboolean

        CRLF 변환 같은 필터를 적용할지 여부

      • disablePathspecMatchboolean

        path에 지정된 경로를 pathspec이 아닌 정확한 파일 경로로 취급할지 여부

      • dryRunboolean

        충돌을 확인하되 실제 변경은 하지 않는 드라이 런을 수행할지 여부

      • filePermnumber

        새 파일을 만들 때 사용할 모드. 기본값은 blob에 따라 0644 또는 0755

      • forceboolean

        수정된 파일을 폐기할 수도 있도록 워킹 디렉터리를 대상과 일치시키는 데 필요한 모든 동작을 수행할지 여부

      • ourLabelstring

        충돌에서 공통 our 쪽의 이름

      • overwriteIgnoredboolean

        체크아웃 중 무시된 파일을 덮어쓸지 여부. 기본값은 true

      • pathstring

        체크아웃할 경로를 추가해요. disablePathspecMatch가 설정되지 않았다면 이 경로는 <a href="https://git-scm.com/docs/gitglossary.html#Documentation/gitglossary.txt-aiddefpathspecapathspec">pathspec</a> 패턴이에요. 경로를 지정하지 않으면 모든 파일을 체크아웃해요. 그렇지 않으면 지정된 경로만 체크아웃해요.

      • recreateMissingboolean

        안전 모드에서 존재하지 않는 파일을 생성할지 여부. 기본값은 false

      • refreshboolean

        작업 전에 디스크에서 인덱스와 git attributes를 새로 고칠지 여부. 기본값은 true

      • removeIgnoredboolean

        워킹 디렉터리에서 무시된 파일을 제거할지 여부. 기본값은 false

      • removeUntrackedboolean

        워킹 디렉터리에서 추적되지 않은 파일을 제거할지 여부. 기본값은 false

      • safeboolean

        기존 파일이나 변경 사항을 덮어쓰지 않으면서 새 파일 생성은 허용하는 안전한 방식으로 체크아웃을 수행할지 여부. 기본값

      • skipUnmergedboolean

        인덱스에 병합되지 않은 항목이 있는 파일을 건너뛸지 여부. 기본값은 false

      • targetDirstring

        체크아웃할 디렉터리

      • theirLabelstring

        충돌에서 공통 their 쪽의 이름

      • updateIndexboolean

        체크아웃이 업데이트된 파일 정보을 인덱스에 기록하지 못하게 할지 여부. 기본값은 true

      • updateOnlyboolean

        이미 존재하는 파일의 내용만 업데이트할지 여부. 설정하면 파일을 생성하거나 삭제하지 않아요. 기본값은 false

      • useOursboolean

        충돌 시 파일의 stage 2 버전("ours")을 사용해서 체크아웃을 진행할지 여부. 기본값은 false

      • useTheirsboolean

        충돌 시 파일의 stage 3 버전("theirs")을 사용해서 체크아웃을 진행할지 여부. 기본값은 false

    • mainlinenumber

      병합 커밋에 대한 부모 번호(1부터 시작). 병합 커밋을 체리픽할 때 mainline 부모는 체리픽을 가져올 대상으로 선택하는 부모예요. mainline은 병합이 수행된 기준 브랜치

    • mergeOptionsMergeOptions

      병합 커밋을 체리픽할 때의 병합 해결을 위한 옵션

      • diff3Styleboolean

        diff3 스타일 파일을 생성할지 여부

      • failOnConflictboolean

        충돌이 발생하면 충돌 해결을 계속 시도하지 않고 즉시 종료할지 여부

      • filFavorFileFavor

        충돌 해결에서 우선할 쪽

      • findRenamesboolean

        파일 이름 변경을 감지할지 여부

      • ignoreWhitespaceboolean

        모든 공백을 무시할지 여부

      • ignoreWhitespaceChangeboolean

        공백 양의 변경을 무시할지 여부

      • ignoreWhitespaceEolboolean

        줄 끝의 공백을 무시할지 여부

      • minimalboolean

        최소 diff를 찾기 위해 추가 시간을 사용할지 여부

      • noRecursiveboolean

        병합되는 커밋에 여러 병합 베이스가 있는 경우, 여러 병합 베이스를 병합해 재귀 병합 베이스를 만들지 않고 첫 번째 베이스만 사용할지 여부

      • patienceboolean

        "patience diff" 알고리즘을 사용할지 여부

      • recursionLimitnumber

        크로스 크로스 병합에서 가상 병합 베이스를 만들기 위해 공통 조상을 병합하는 최대 횟수. 이 제한에 도달하면 다음 조상은 병합을 시도하지 않고 그대로 사용해요. 기본값은 무제한

      • renameThresholdnumber

        파일을 이름 변경으로 간주할 유사도(기본값 50)

      • simplifyAlnumboolean

        단순화된 diff 파일을 위해 영숫자가 아닌 구간을 축약할지 여부

      • skipReucboolean

        생성된 인덱스에 REUC 확장을 기록하지 않을지 여부

      • standardStyleboolean

        표준 충돌 병합 파일을 생성할지 여부

      • targetLimitnumber

        이름 변경을 검사할 유사도 소스의 최대 개수(기본값 200). 이름 변경 후보(추가/삭제 쌍)의 수가 이 값보다 크면 부정확한 이름 변경 감지를 중단해요. 이 설정은 merge.renameLimit 구성 값을 재정의해요.

에러

  • Error

    커밋이 병합 커밋인데 mainline이 지정되지 않은 경우.

  • Error

    체리픽 작업 중 충돌이 발생한 경우.

예제

ts
import { openRepository } from 'es-git';

const repo = await openRepository('./path/to/repo');
const cherrypickCommit = repo.getCommit('cherrypick-commit');

// Cherrypick the commit onto HEAD and working tree
repo.cherrypick(cherrypickCommit);
repo.cleanupState();

// Cherrypick the commit against our commit selecting the first parent as mainline (This is necessary because, for merge commits, there is ambiguity about which side of the merge should be treated as the baseline.)
repo.cherrypick(cherrypickCommit, { mainline: 1 });
repo.cleanupState();

// Prevent working tree changes (dry run) but compute conflicts
repo.cherrypick(cherrypickCommit, { checkoutOptions: { dryRun: true } });
repo.cleanupState();

// Cherrypick the commit against our commit selecting the first parent as mainline and prevent working tree changes (dry run) but compute conflicts
repo.cherrypick(cherrypickCommit, { mainline: 1, checkoutOptions: { dryRun: true } });
repo.cleanupState();

MIT 라이선스에 따라 배포됩니다.