To learn more about Git submodules, you can refer to the official Git documentation: Git Tools - Submodules. Git submodules enable you to incorporate and track the version history of external resources. To maintain and update shared resources easily, you can also integrate them as Git submodules. You can manually share test artifacts with the Test Artifacts Sharing feature provided by Katalon Studio. While working on a Katalon Studio project, you might want to use test artifacts from external resources. Using Git Submodules to share Test Artifacts in Katalon Studio # Rename it for the next command will delete it from working tree # If you want to keep submodule's files in working tree. To remove a submodule named a-submodule from a repository: # Frist remove the from index Note if you only care about changes of each submodule, use git status instead. Or you can do this with help with git submodule status which outputs some information for each submodule: $ git submodule statusĮ8aecd.ebd a-submodule-name (heads/main) You can do that with a command: # Output the content of. Check that file to get all the submodules. Since all the submodules in a repository are recorded in the. Git does not provide a command something like git submodule list to list all the submodules. For example, stashing changes for all your submodules: # Stash changes for all submodules Git has a submodule foreach command for you to manipulate multiple submodules. # Pull and merge updates form upstream branch Or you can do it manually: # Switch to the submodule's directory $ git submodule update -remote -merge a-submodule To pull updates from remote for a submodule, an easy way is to run: # Let Git to go into the submodule's directory and get updates for a-submodule $ git commit -m 'update changes of submodule a-submodule' ![]() # Commit the submodule's changes to the top repository ![]() ![]() (commit or discard the untracked or modified content in submodules) " to discard changes in working directory) # Switch to the main repository directory $ git commit -m 'feat: add some functionly' To commit changes in a submodule, first commit in its own repository and then commit for the main repository: # Commit changes in the submodule directory Or you can add an -recurse-submodules option to the git clone command to automatically initialize and fetch each submodule recursively. You can also combine the two commands into one: # Initialize and update submodules (with nested ones) with one command If there are nested submodules, add -recursive option to these two commands. To fetch the files in the submodules, you need to run two more commands: # Initialize local configuration file If you clone a repository with submodules inside it as you do usually like below, you will get empty directories for submodules. in the submodule’s directory to get the content back. Afterwards if you get back to the branch treating it as a submodule, you need to execute git checkout. At this time, an option -f is needed to checkout. Note: If you switch to a branch in which the subdirectory not being as a submodule,you may get an error for the subdirectory will be overwritten. $ git commit -m 'switch subdirectory csvlib as a submodule' Then add a subdirectory as a submodule: # Init csvlib as a repoĪdding existing repo at 'csvlib' to the index To add a submodule from a subdirectory that has been tracked, you need to remove it first: # First remove the subdirectory named csvlib from index You can also switch a subdirectory to a submodule. git directory while they stay in the submodule’s directory in the old versions. git data is stored the main repository’s. Note: In new git versions, the submodule’ s. gitmodules and a-submoduleĪs you see, Git treats the new submodule as a file with special mode (1600000) in a commit.įor a repository with submodules inside it, it is called the main repository. # Use status to check what the above command stages # the submodule and its remote repository. gitmodules which contains the mapping relation of ![]() To create a new sub repository whose content has not existed in the repository: # Add a submodule named a-submodule from an remote repository This article shows you how to manipulate a submodule. Git’s submodule tool allows you to create a child repository as a submodule inside a repository.
0 Comments
Leave a Reply. |