![]() ![]()
#GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY UPDATE#You can treat the rack directory as a separate project and then update your superproject from time to time with a pointer to the latest commit in that subproject. That is a special mode in Git that basically means you’re recording a commit as a directory entry rather than a subdirectory or a file. ![]() Notice the 160000 mode for the rack entry. first commit with submodule rackĢ files changed, 4 insertions(+), 0 deletions(-) When you commit, you see something like this: $ git commit -m 'first commit with submodule rack' You can’t record a submodule at master or some other symbolic reference. This is an important point with submodules: you record them as the exact commit they’re at. When you make changes and commit in that subdirectory, the superproject notices that the HEAD there has changed and records the exact commit you’re currently working off of that way, when others clone this project, they can re-create the environment exactly. Instead, Git records it as a particular commit from that repository. +++ -0,0 +1 commit 08d709f78b8c5b0fbeb7821e37fa53e69afcf433Īlthough rack is a subdirectory in your working directory, Git sees it as a submodule and doesn’t track its contents when you’re not in that directory. If you run git diff on that, you see something interesting: $ git diff -cached rack The other listing in the git status output is the rack entry. This is how other people who clone this project know where to get the submodule projects from. It’s pushed and pulled with the rest of your project. It’s important to note that this file is version-controlled with your other files, like your. If you have multiple submodules, you’ll have multiple entries in this file. This is a configuration file that stores the mapping between the project’s URL and the local subdirectory you’ve pulled it into: $ cat. If you run git status right after you add the submodule, you see two things: $ git statusįirst you notice the. You can go into that subdirectory, make changes, add your own writable remote repository to push your changes into, fetch and merge from the original repository, and more. Now you have the Rack project under a subdirectory named rack within your project. Initialized empty Git repository in /opt/subtest/rack/.git/ You add external projects as submodules with the git submodule add command: $ git submodule add git:///chneukirchen/rack.git rack The first thing you should do is clone the external repository into your subdirectory. Suppose you want to add the Rack library (a Ruby web server gateway interface) to your project, possibly maintain your own changes to it, but continue to merge in upstream changes. This lets you clone another repository into your project and keep your commits separate. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. Git addresses this issue using submodules. #GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY CODE#The issue with vendoring the code into your own project is that any custom changes you make are difficult to merge when upstream changes become available. The issue with including the library is that it’s difficult to customize the library in any way and often more difficult to deploy it, because you need to make sure every client has that library available. #GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY INSTALL#You’re likely to have to either include this code from a shared library like a CPAN install or Ruby gem, or copy the source code into your own project tree. Instead of writing your own Atom-generating code, you decide to use a library. Suppose you’re developing a web site and creating Atom feeds. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. ![]() It often happens that while working on one project, you need to use another project from within it. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |