programing

다른 분기의 커밋된 복사본이 있는 파일의 현재 작업 복사본

iphone6s 2023. 7. 6. 21:57
반응형

다른 분기의 커밋된 복사본이 있는 파일의 현재 작업 복사본

파일이 있는 레포가 있습니다.foo본지점에서저는 바 지점으로 전환하여 몇 가지 변경 사항을 적용했습니다.foo이제 어떻게 실행할 수 있습니까?git diff이 복사본(아직 커밋되지 않음)과 마스터 브랜치 복사본 사이에 있습니까?

다음은 저에게 적합합니다.

git diff master:foo foo

과거에는 다음과 같은 경우가 있었습니다.

git diff foo master:foo

작업 트리를 특정 지점 이름과 비교하려고 하므로 다음과 같은 작업을 수행할 수 있습니다.

git diff master -- foo

이 git-diff 형식에서 나온 것입니다(git-diff 맨 페이지 참조).

   git diff [--options] <commit> [--] [<path>...]
       This form is to view the changes you have in your working tree
       relative to the named <commit>. You can use HEAD to compare it with
       the latest commit, or a branch name to compare with the tip of a
       different branch.

참고로, 또한 있습니다.--cached(일명)--staged작업 트리의 모든 항목이 아닌 준비한 항목의 차이를 보는 옵션:

   git diff [--options] --cached [<commit>] [--] [<path>...]
       This form is to view the changes you staged for the next commit
       relative to the named <commit>.
       ...
       --staged is a synonym of --cached.
git difftool tag/branch filename

또한:git diff master..feature foo

부터git diff foo master:foo저는 디렉토리에서 작동하지 않습니다.

git diff mybranch master -- file

또한 작동해야 합니다.

효과적인 기능:

git diff master ./relative-path-to-foo

현재 분기와 비교하여 로컬 변경 내용을 보려면 다음과 같이 하십시오.

git diff .

다른 기존 분기와 비교하여 로컬 변경 내용을 보려면 다음과 같이 하십시오.

git diff <branch-name> .

특정 파일의 변경 내용을 보려면 다음과 같이 하십시오.

git diff <branch-name> -- <file-path>

실행해야 합니다.git fetch처음에

이름이 붙은 지점이 있다고 가정해 보겠습니다.master그리고라는 이름의 가지.feature그리고 당신은 특정한 파일을 확인하고 싶습니다.my_file그러면:

  1. git diff master..feature /Path/to/my_file의 커밋된 버전 간의 차이를 보여줍니다.my_file분기하여master그리고.feature.
  2. git diff master -- /Path/to/my_file작업 디렉토리(미사용 파일)와 분기 간의 차이를 보여줍니다.mastermy_file.

언급URL : https://stackoverflow.com/questions/9113280/diff-current-working-copy-of-a-file-with-another-branchs-committed-copy

반응형