programing tip

Git 서브 모듈을 추적하지 않는 상태에서 제거하는 방법?

itbloger 2020. 6. 22. 08:04
반응형

Git 서브 모듈을 추적하지 않는 상태에서 제거하는 방법?


Git의 서브 모듈에서 추적되지 않은 내용을 제거 할 수없는 것 같습니다. 실행 git status수율 :

# 지점 마스터
# 커밋을 위해 변경되지 않은 변경 사항 :
# (커밋 할 내용을 업데이트하려면 "git add ..."를 사용하십시오)
# ( "git checkout-..."을 사용하여 작업 디렉토리의 변경 사항을 버립니다)
# (서브 모듈에서 추적되지 않거나 수정 된 내용을 커밋하거나 버리십시오)
#
# 수정 : 번들 / 스닙 메이트 (추적되지 않은 콘텐츠)
# 수정 : 번들 / 서라운드 (추적되지 않은 콘텐츠)
# 수정 : 번들 / 트레일 링-공백 (추적되지 않은 내용)
# 수정 : 번들 / 젠 코딩 (추적되지 않은 콘텐츠)
#
커밋에 추가 된 변경 사항 없음 ( "git add"및 / 또는 "git commit -a"사용)

--ignore-submodules매개 변수를 추가하면 이 메시지가 숨겨집니다. 하지만이 먼지를 더 적절하고 핵심적인 방식으로 제거 할 수있는 방법이 있는지 궁금합니다.


자식 상태는 추적되지 않은 내용을보고하므로 실제 상태를 유지하는 실제 방법은 해당 하위 모듈 각각에 들어가는 것입니다.

  • 추적되지 않은 내용을 추가하고 커밋
  • 또는 .gitignore각 모듈 에 따라 추적되지 않은 내용을 참조하십시오 .
  • 또는 당신은 서브 모듈의 동일한 무시 컨텐츠를 추가 할 수 있습니다 .git/info/exclude로, peci1의 보고서 코멘트에 .
  • 또는 ezraspectre답변에 언급 된대로 서브 모듈 사양에 더티를 추가하십시오 (위).

    git config -f .gitmodules submodule.<path>.ignore untracked
    
  • 또는 전역 .gitignore 파일을 추가 하십시오 (종종 ~/.gitignore-global). 예를 들어처럼 .DS_Store또는 제 경우 Carthage/Build에 의해보고 된 마리아 서니코멘트 . 참조 .gitginore맨 페이지를 :

사용자가 모든 상황에서 Git이 무시하도록하려는 패턴 (예 : 사용자가 선택한 편집기로 생성 된 백업 또는 임시 파일)은 일반적으로 core.excludesFile사용자의에 지정된 파일로 이동합니다 ~/.gitconfig. 기본값은 $XDG_CONFIG_HOME/git/ignore입니다. $XDG_CONFIG_HOME설정되어 있지 않거나 비어 있으면 $HOME/.config/git/ignore대신 사용됩니다.


블로그 게시물전체적으로 작동한다는 것을 알았 습니다 . 파일 ignore = dirty의 각 항목에 옵션을 추가 .gitmodules합니다.

[submodule "zen-coding-gedit3"]
    path = zen-coding-gedit3
    url = git://github.com/leafac/zen-coding-gedit3.git
    ignore = dirty

각 하위 모듈 디렉토리로 이동하여 분리 된 자식 역할을 할 수도 있습니다. 예를 들면 다음과 같습니다.

cd my/project/submodule
git status

... / 수정 된 파일의 목록을 가져옵니다 /

git add .  //to add all of them to commit into submodule
git commit -m "message to your submodule repo"

당신은 또한 원격 하위 모듈 저장소를 업데이트 할 수 있습니다

git submodule update

아무튼


detached HEAD하위 모듈 분기 의 때문일 것 입니다. 당신의 서브 모듈의 경로로 (예를 : 이동 ./bundle/snipmate), 다음 git checkout master.

나는 이것이 도움이되기를 바랍니다 :)


어제 12 개의 서브 모듈에 가까운 프로젝트 에서이 문제에 갇혔습니다.

git status 출력을 보여주고 있었다.

# On branch master
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#   modified:   proj1 (untracked content)
#   modified:   proj1 (modified content, untracked content)
#   ...

비 추적 콘텐츠 오류를 해결하려면, 나는 모든 서브 모듈에서 비 추적 파일 (모든했다 제거했다 *.pyc, *.pyo사용 a 파이썬에 의해 생성 된 파일) .gitignore.

다른 것을 해결하기 위해 git submodule update각 서브 모듈을 업데이트 한 것을 실행해야했습니다 .


내 상황에서 ZF2 환경에서 새 모듈의 시작점으로 모듈을 복제합니다. 이것이하는 일은 디렉토리에 자체 .git 폴더를 넣는 것입니다.

Solution in this case is to delete the .git folder (you will likely need to show hidden files to view it).


This worked out just fine for me:

git update-index --skip-worktree

If it doesn't work with the pathname, try the filename. Let me know if this worked for you too.

Bye!


This probably happens when you have another .git [hidden folder] inside the particular folder..

modified: ./../.. (modified content, untracked content)

make sure your sub-directory does not contains this .git folder.

If That is the case the issue can be resolved by deleting the .git folder manually from the sub directory.


I prefer to use SourceTree, so the solution for me was to open the submodule repo in SourceTree which shows me list of all untracked files. I then group selected them all then used "Remove".

I was able to do this because I knew all the untracked files weren't actually needed.


If this is a temporary issue, you can go into the submodule folder and run git reset HEAD --hard but you will lose all your changes inside of the submodule.

참고URL : https://stackoverflow.com/questions/5126765/how-to-get-rid-of-git-submodules-untracked-status

반응형