sourcecode

추적되지 않은 내용을 추적하는 방법은 무엇입니까?

copyscript 2023. 9. 11. 21:58
반응형

추적되지 않은 내용을 추적하는 방법은 무엇입니까?

제 원래 질문에 대해서는 실선 아래를 참조하세요.

로컬 디렉토리에 추적되지 않은 폴더가 있습니다.가 실행할 때git status, 알겠습니다.

Changed but not updated:
modified:   vendor/plugins/open_flash_chart_2 (modified content, untracked content)

를 치면git add vendor/plugins/open_flash_chart_2그럼 시도해보세요git status다시 말하지만 아직도 추적되지 않았다고 합니다.무슨 일이야?


제 최근 30분간의 간단한 요약본은 다음과 같습니다.

  • Github 내 Github repo Github repo 하지 했습니다 을 를 했습니다 을 하지 vendor/plugins/open_flash_chart_2플러그인.구체적으로 내용이 없고 폴더 아이콘에 녹색 화살표가 표시됩니다.

  • 시험을 마친git submodule init

    No submodule mapping found in .gitmodules for path 'vendor/plugins/open_flash_chart_2'
    
  • 시험을 마친git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

    vendor/plugins/open_flash_chart_2 already exists in the index
    
  • git status

    modified: vendor/plugins/open_flash_chart_2 (untracked content)
    
  • 이름이 지정된 파일에 대해 사냥됨.gitmodules내 저장소/로컬 디렉토리에 있지만 찾을 수 없습니다.

서브모듈이 제대로 작동하도록 하려면 어떻게 해야 하나요?


이 내용은 관련이 없을 수도 있지만(도움이 될 경우를 대비해 포함합니다) 입력할 때마다git commit -a의 나의git commit -m "my comments"오류를 던집니다: , 가

E325: ATTENTION
Found a swap file by the name ".git\.COMMIT-EDITMSG.swp"
         dated: Thu Nov 11 19:45:05 2010
     file name: c:/san/project/.git/COMMIT_EDITMSG
      modified: YES
     user name: San   host name: San-PC
    process ID: 4268
While opening file ".git\COMMIT_EDITMSG"
         dated: Thu Nov 11 20:56:09 2010
  NEWER than swap file!  
Swap file ".git\.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
Swap file ".git\.COMMIT_EDITMSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

저는 Github의 완전한 신입인데, 서류를 검토하려고 노력했음에도 불구하고, 저는 이러한 특정한 문제들 때문에 조금 당황스럽습니다.감사해요.

를 했습니다.vendor/plugins/open_flash_chart_2"gitlink" 항목으로 정의했지만 하위 모듈로 정의한 적은 없습니다.사실상 git 서브모듈이 사용하는 내부 기능(gitlink 항목)을 사용하고 있지만 서브모듈 기능 자체는 사용하고 있지 않습니다.

당신은 아마 다음과 같은 일입니다

git clone git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2
git add vendor/plugins/open_flash_chart_2

이 마지막 명령이 문제입니다.vendor/plugins/open_flash_chart_2는 독립적인 Git 저장소로 시작합니다.일반적으로 이러한 하위 리포지토리는 무시되지만 git add to explicitly add to add to add it comit. 그러면 디렉토리의 내용을 추가하는 대신 하위 리포지토리의 HEAD 커밋을 가리키는 gitlink 항목이 생성됩니다.git add가 그러한 "semi-sub module"을 만드는 것을 거부한다면 좋을 것입니다.

일반 디렉터리는 Git에서 트리 개체로 표시되며, 트리 개체는 포함된 개체(일반적으로 다른 트리 및 blob 개체-디렉토리 및 파일)에 이름과 권한을 부여합니다.하위 모듈은 "gitlink" 항목으로 표시되며, gitlink 항목에는 하위 모듈의 HEAD 커밋의 개체 이름(해시)만 포함됩니다. " 저장소의 소 스 "는 "다 "되어 "에 "에 명시되어 ..gitmodules일및)).git/configsubmodule (파일).

해당 커밋에 대한 원본 저장소를 기록하지 않고 특정 커밋을 가리키는 항목이 있습니다.이 문제는 깃링크를 적절한 서브모듈로 만들거나 깃링크를 제거하고 "일반" 콘텐츠(일반 파일 및 디렉터리)로 대체하여 해결할 수 있습니다.

Turn It into a Proper Submodule

제대로 정의할 수 있는 유일한 비트vendor/plugins/open_flash_chart_2서브모듈이 A인 것처럼.gitmodulesfile. 보통 (아직 베어 깃링크 엔트리로 추가하지 않았다면) 그냥git submodule add:

git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

As you found, this will not work if the path already exists in the index. The solution is to temporarily remove the gitlink entry from the index and then add the submodule:

git rm --cached vendor/plugins/open_flash_chart_2
git submodule add git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

기존 하위 리포지토리를 사용합니다(즉, 소스 리포지토리를 다시 복제하지 않음)..gitmodules다음과 같은 파일:

[submodule "vendor/plugins/open_flash_chart_2"]
    path = vendor/plugins/open_flash_chart_2
    url = git://github.com/korin/open_flash_chart_2_plugin.git vendor/plugins/open_flash_chart_2

또한 주 저장소에 유사한 항목을 입력합니다..git/config(이외의 경우)path설정).

이를 실행하면 적절한 서브모듈을 갖게 됩니다.저장소를 복제할 때(또는 GitHub로 푸시하고 거기서 복제할 때), 다음을 통해 하위 모듈을 다시 초기화할 수 있어야 합니다.git submodule update --init.

Replace It with Plain Content

다음 단계에서는 하위 저장소가vendor/plugins/open_flash_chart_2보존하려는 로컬 기록이 없습니다(즉, 하위 저장소의 현재 작업 트리만 신경 쓰이지 기록은 신경 쓰지 않습니다).

If you have local history in the sub-repository that you care about, then you should backup the sub-repository’s .git directory before deleting it in the second command below. (Also consider the git subtree example below that preserves the history of the sub-repository’s HEAD).

git rm --cached vendor/plugins/open_flash_chart_2
rm -rf vendor/plugins/open_flash_chart_2/.git # BACK THIS UP FIRST unless you are sure you have no local changes in it
git add vendor/plugins/open_flash_chart_2

이번에는 디렉토리를 추가할 때 하위 저장소가 아니므로 파일이 정상적으로 추가됩니다.아쉽게도 저희가 삭제를 했기 때문에..git디렉토리 소스 저장소를 최신 상태로 유지하는 매우 쉬운 방법은 없습니다.

You might consider using a subtree merge instead. Doing so will let you easily pull in changes from the source repository while keeping the files “flat” in your repository (no submodules). The third-party git subtree command is a nice wrapper around the subtree merge functionality.

git rm --cached vendor/plugins/open_flash_chart_2
git commit -m'converting to subtree; please stand by'
mv vendor/plugins/open_flash_chart_2 ../ofc2.local
git subtree add --prefix=vendor/plugins/open_flash_chart_2 ../ofc2.local HEAD
#rm -rf ../ofc2.local # if HEAD was the only tip with local history

Later:

git remote add ofc2 git://github.com/korin/open_flash_chart_2_plugin.git
git subtree pull --prefix=vendor/plugins/open_flash_chart_2 ofc2 master

git subtree push --prefix=vendor/plugins/open_flash_chart_2 git@github.com:me/my_ofc2_fork.git changes_for_pull_request

git subtree는 또한.--squash원본 저장소의 기록을 기록에 통합하는 것을 방지하면서도 업스트림 변경사항을 풀링할 수 있는 옵션입니다.

I just had the same problem. The reason was because there was a subfolder that contained a ".git" folder. Removing it made git happy.

  1. 새로운 디렉터리에서 .git 디렉터리를 제거했습니다(이것은 서브모듈 드라마를 만들 수 있습니다).관심 있는 경우 구글에서 검색합니다.)
  2. 그런 다음 rf --cacheed /the/new/directories를 실행했습니다.
  3. 그런 다음 위에서 git add .로 디렉토리를 다시 추가했습니다.

참조 URL https://danielmiessler.com/blog/git-modified-untracked/ #gs.W0C7X6U

Chris Johansen이 OP와 나눈 대화(답장에서 답변으로 연결)에서 제가 알아내야 했던 것을 지적하자면:

git add vendor/plugins/open_flash_chart_2gitlink를 하고, 되지 않은 채 #gitlink다지다지는고l를kdtly .

git add vendor/plugins/open_flash_chart_2/# 슬래시 주목!!

두 번째 양식은 깃링크 없이 추가할 것이며, 내용은 추적 가능합니다..gitdir는 편리하게 자동으로 무시됩니다.고마워요 크리스!

저는 피터 라다가 제안한 "가짜 서브모듈"이라고 불리는 속임수를 항상 사용합니다.

http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb

몇 가지 시나리오에서 매우 유용합니다(예: elpa/el-get 패키지 디렉터리 내부의 모든 깃 저장소의 현재 헤드를 포함하여 저장소에 모든 Emacs 구성을 유지하는 데 사용하므로 일부 업데이트로 인해 오류가 발생할 때 알려진 작동 버전으로 쉽게 롤백/포워드할 수 있습니다).

저는 서브폴더에서 .git 파일을 삭제하여 이 문제를 해결했습니다.

  1. 먼저 하위 폴더에서 .git 파일을 삭제합니다.
  2. 그런 다음 gitrm -rf --cacheed your_subfolder_name 코드를 실행하여 git에서 하위 폴더를 제거합니다.
  3. 그런 다음 git add . 명령으로 폴더를 다시 추가합니다.

http://progit.org/book/ch6-6.html

서브모듈에 대해 조금 더 알아보려면 이 글을 읽어보셔야 할 것 같습니다.글도 잘 쓰였고 읽는 데도 시간이 많이 걸리지 않습니다.

서브모듈이 많은 대형 프로젝트에서도 같은 문제가 있었습니다.여기 Chris JohnsenVonCe답변을 바탕으로 저는 기존의 모든 gitlink 항목을 반복하여 적절한 서브모듈로 추가하는 짧은 bash 스크립트를 구축합니다.

#!/bin/bash

# Read all submodules in current git
MODULES=`git ls-files --stage | grep 160000`

# Iterate through every submodule path
while read -r MOD; do
  # extract submodule path (split line at whitespace and take string with index 3)
  ARRIN=(${MOD})
  MODPATH=${ARRIN[3]}

  # grep module url from .git file in submodule path
  MODURL=`grep "url = " $MODPATH/.git/config`
  MODURL=${MODURL##*=}

  # echo path and url for information
  echo $MODPATH
  echo $MODURL

  # remove existing entry in submodule index
  git rm --cached $MODPATH
  # add new entry in submodule index
  git submodule add $MODURL $MODPATH
done <<< "$MODULES"

이것이 저를 위해 고쳤습니다, 도움이 되었으면 좋겠습니다.

이 일은 제게 아주 잘 되었습니다.

git update-index --patch-worktree

경로 이름과 함께 사용할 수 없으면 파일 이름을 사용해 보십시오.이것도 당신에게 효과가 있었는지 알려주세요.

잘 가요

같은 문제가 있었지만 이번 토론에서는 해결되지 않았습니다.

스레드 오프닝에서 설명한 대로 서브모듈 문제도 쳐봤습니다.

% git status          
# On branch master
# Changes not staged for commit:
#   modified:   bundle/taglist (untracked content)

해시에 첨부된 -dirty를 인식한 차이를 살펴보니 문서를 다시 읽고 문제를 해결했습니다.http://web.mit.edu/jhawk/mnt/spo/git/git-doc/user-manual.html "하위 모듈이 있는 함정" 섹션 보기

이유는 하위 모듈 내에 변경 사항이 있거나 추적되지 않은 내용이 있었기 때문입니다.저는 먼저 서브모듈 디렉토리로 가서 "git add" + "git commit"를 수행하여 서브모듈 내의 모든 콘텐츠를 추적해야 했습니다.

Then "git status" on the master stated
% git commit
# On branch master
# Changes not staged for commit:
#   modified:   bundle/taglist (new commits)

이제 서브모듈의 이 새로운 HEAD를 마스터 모듈에 커밋할 수 있습니다.

최근 계약 프로젝트(비기밀)를 진행하던 중 이 문제를 발견했습니다.물론 제가 코드를 실행해야 하는 시스템은 보안을 위해 인터넷에 접속할 수 없기 때문에 composer와 npm을 사용하여 의존성을 설치하는 것이 큰 고통이 되었습니다.

동료와 많은 고민 끝에 우리는 작곡가 설치나 npm 설치를 하기보다는 그냥 윙핑해서 의존관계를 복사하기로 했습니다.

이를 통해 공급업체와 npm_modules를 gitignore에 추가하지 않았습니다.이 문제를 접했을 때입니다.

Changed but not updated:
modified:   vendor/plugins/open_flash_chart_2 (modified content, untracked content)

나는 이것을 구글에서 조금 검색했고 SO에서 이 유용한 스레드를 찾았습니다.Git에 너무 프로답지도 않고, 작업하는 동안 약간 도취되어 벤더 폴더에서 모든 서브모듈을 검색했을 뿐입니다.

find . -name ".git"

이것 때문에 저는 4-5개의 의존성을 갖게 되었습니다.이 모든 .git 폴더와 voila를 제거했습니다. 효과가 있었습니다.해킹인거 알아요, 어쨌든 별것 아닌거죠.SO의 신이시여, 용서해 주십시오!다음 번에는 깃링크를 읽고 오마이티 리누스 토발즈에게 복종할 것을 약속합니다.

이 질문은 이미 답변이 끝났지만, 이 메시지를 받았을 때 알게 된 내용을 추가하려고 생각했습니다.

레포(repo)가 있습니다.playground많은 샌드박스 앱을 포함하고 있습니다.에서 두 의 새로운 했습니다에 했습니다.playground자습서의 레포를 복제하여 디렉토리를 생성합니다.결과적으로 새로운 앱의 git 항목은 튜토리얼의 repo를 가리켰고 내 repo를 가리켰습니다.e를 삭제하는 이었습니다..git를 검색할 수 .mv들 밖에 .playground리,그mv그들은 뒤로 돌아 다닙니다.git add .효과가 . 그 후로 효과가 있었습니다.

먼저 디렉토리(vendor/plugins/open_flash_chart_2)로 이동하고 DELETE를 선택합니다.


다음:

git rm --cached vendor/plugins/open_flash_chart_2  
git add .  
git commit -m "Message"  
git push -u origin master  

git status  

산출량


지점이 'origin/master'로 최신 상태입니다.
commit, clean nothing to commit, working 디렉토리 clean

을 슬래시 가 을 를 하지 했어야 했어야 하지 /

틀렸습니다:

[submodule "/sources/meta-security"]
        path = /sources/meta-security
        url = git@gitlab.com:yocto/meta-security.git

정답:

[submodule "sources/meta-security"]
        path = sources/meta-security
        url = git@gitlab.com:yocto/meta-security.git

변경 후 다음 명령으로 문제가 해결되었습니다.

git submodule update --init

내게 유일하게 도움이 된 건

  • 삭제 .git 하위 디렉터리 안의 리의더당더의리
  • 그 서브디렉토리를 메인디렉토리에서 밖으로 옮기면
  • git add .
  • git commit -m "cleaning up"
  • git push
  • 하위 디렉터리를 다시 주 디렉터리로 이동
  • 또다시 git add .
  • git commit -m "message"
  • git push

이제 효과가 있습니다.

언급URL : https://stackoverflow.com/questions/4161022/how-to-track-untracked-content

반응형