![]() ![]() To start with, we can simply check out this commit: $ git checkout 0.1.1 This is the version we want to have in our project. Now, in the log output, we spot a commit that is tagged "0.1.1": 83298f7 (HEAD, master) update. We change into the Submodule's base folder and call the "log" command: $ cd lib/ToProgress/īefore we take a look at the actual history, I'd like to stress an important point: Git commands are context-sensitive! By moving into the Submodule directory on the command line, all Git commands that we perform will be executed in the context of the Submodule, not its parent repository. ![]() First, we'll have a look at the library's commit history. Let's say we want to have an older version of our "ToProgress" library in our project. Pointing at a specific revision, on the other hand, guarantees that the correct code is always present. This is because the contents of a branch can change over time, as new commits arrive. Unlike normal Git repositories, Submodules always point to a specific commit - not a branch. Therefore, like with any Git repository, you have to decide which revision of your Submodule shall be checked out. (b) If you used a simple "git clone" command without this option, you need to initialize the Submodules afterwards with "git submodule update -init -recursive"Ī Git repository can have countless committed versions, but only one version's files can be in your working directory. (a) You can add the "-recurse-submodules" option to "git clone" this tells Git to also initialize all Submodules when the cloning is finished. You have two options to end up with a populated "lib" folder (or wherever else you choose to save your Submodules "lib" is just an example): Our "lib" folder, however, would stay empty. This shows when you clone a project that contains Submodules: by default, the "git clone" command only downloads the project itself. You already know that a project repository does not contain its Submodules' files the parent repository only saves the Submodules' configurations as part of version control. Git regards adding a Submodule as a modification like any other - and requests you to commit it to the repository: $ git commit -m "Add 'ToProgress' Javascript library as Submodule"Ĭongratulations: we've now successfully added a Submodule to our main project! Before we look at a couple of use cases, let's see how you can clone a project that already has Submodules added. Let's have a look at our project's status: $ git status Please do yourself a favor and always use proper Git commands to manage Submodules. Therefore, it's highly recommended not to mess with configuration files and values manually. Git's internal management of Submodules is quite complex (as you can already guess from all the. As you can see from the ".git" subfolder contained herein, this is a fully-featured Git repository.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |