User Tools

Site Tools


computing:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
computing:git [2026/04/27 15:01] – [Move Between Branches] oscarcomputing:git [2026/04/27 18:54] (current) oscar
Line 5: Line 5:
 ^Task^Command^ ^Task^Command^
 |Start a new repo|git init| |Start a new repo|git init|
-|Clone an existing repo|git clone <url>|+|Clone an existing repo|git clone <url> \\ git clone http://192.168.178.96:3000/<Repository Name>|
 ==== Configure Git ==== ==== Configure Git ====
 ^Task^Command^ ^Task^Command^
Line 105: Line 105:
 |Pull changes and then rebase your current branch|git pull --rebase| |Pull changes and then rebase your current branch|git pull --rebase|
 |Pull changes and then merge them into your current branch|git pull origin main OR \\ git pull| |Pull changes and then merge them into your current branch|git pull origin main OR \\ git pull|
 +
 +==== Submodules ====
 +=== Adding a Submodule ===
 +Navigate to the root directory of ‘main-project’ and run the following command:
 +  git submodule add <mysubmodule-url>
 +This command adds ‘mysubmodule’ as a submodule to ‘main-project’. It clones ‘mysubmodule’ into a subdirectory of ‘main-project’ and creates a special file called **.gitmodules**. This file tracks the mapping between the project URL and the local subdirectory you've pulled it into.
 +
 +After adding the submodule, you need to commit this change to your repository:
 +  git commit -m "Added util-methods submodule"
 +
 +Now, you can import and use function from 'mysubmodule' in your 'main-project' just like you would with any local module.
 +
 +=== Updating a Submodule ===
 +Navigate to the ‘mysubmodule’ directory within ‘main-project’ and pull the latest changes:
 +  cd mysubmodule
 +  git pull origin master
 +
 +After pulling the latest changes, navigate back to the root directory of ‘main-project’ and commit this update:
 +  cd ..
 +  git commit -m "Updated mysubmodule submodule"
 +
 +Alternatively, you can use the git submodule update --remote command from the root directory of 'main-project' to update all submodules to their latest commiton their master branches. Remember to commit after running this command as well.
 +
 +=== Submodule Caveats ===
 +There are some caveats and things to keep in mind when using Git submodules:
 +
 +  * Updating: Submodules do not automatically stay in sync with the remote repository. You need to go into each submodule and pull the changes manually.
 +  * Committing: If you make changes inside a submodule, you need to commit those changes within the submodule first, then go to the main repository and commit the change to the submodule. This is because the main repository tracks the submodule’s commit.
 +  * Cloning: When you clone a repository, the submodules will not be cloned along with it. You need to use git submodule update --init --recursive or git clone --recursive <repository> to clone the repository and its submodules.
 +  * Pulling: Similarly, when you pull your main repository, it will not pull the new commits of populated submodules. Use the --recurse-submodules option with the git pull to update all the submodules as well.
  
 ==== Important Files ==== ==== Important Files ====
computing/git.1777302117.txt.gz · Last modified: by oscar