개발
다른 저장소의 파일을 그대로 가져와서 사용하는 법
hijae
2023. 4. 30. 00:57
깃을 사용하면서 다른 저장소에 있는 파일을 그대로 나의 프로젝트에 사용하고 싶은 일이 있었다.
이런 경우에는 submodule과 심볼릭 링크를 사용하면 되었다.
$ git submodule add https://github.com/hijae/open-fuji-recipes-profiles
$ ln -s hijae/open-fuji-recipes-profiles/makeFP.py
$ git add .gitmodules makeFP.py
$ git commit -m "add a symbolic link to makeFP.py with the respective submodule"
위와 같이 git에 서브모듈을 설정하고 원하는 파일을 심볼릭 링크로 지정한 후 커밋하면 된다.
혹시나 클론을 받아왔을때 동작하지 않으면 서브모듈을 업데이트 하면 해결된다.
$ git submodule init && git submodule update
git: symlink/reference to a file in an external repository
Is it possible in git to have a "link" to a particular file in a git repo? Like what git submodules do for folders but my question is about a particular file, not a full directory: my-project/
stackoverflow.com