

- GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY HOW TO
- GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY UPDATE
- GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY PRO
- GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY CODE
So after running the script the first time, make sure to update the command. Submodules allow you to keep a Git repository as a subdirectory of another Git repository. When we want to update the chart with new changes in the remote repo, we would do a subtree merge instead. Git addresses this issue using submodules.

Git subtree add -P helm-charts/my-chart helmcharts-stagingĥ. Take all the commits in the staging branch and apply them to master and set /helm-charts/my-chart as the root for the commits.

Subtree split -P my-chart -b helmcharts-stagingĤ. Create a new branch called helmcharts-staging from all the commits impacting /my-chart in the remote repo. Git checkout -b helmcharts-source helmcharts/masterĢ. Let's break down the major steps in the script. Add the repo you want to include as a remote repo in your git config.ģ.I only cared about one particular chart, so Git subtrees to the rescue. You would probably use Git submodules to do this, but submodules would include the entire helmcharts repo (which contains unrelated charts) in my operator repo. Adding the subtree as a remote allows us to refer to it in shorter form: git remote add -f tpope-vim-surround Now we can add the subtree (as before), but now we can refer to the remote in short form: git subtree add -prefix.
GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY CODE
I had some code in a repo that I wanted to include in another while maintaining commit history in both repos (hashes will be different of course). Git subtree allows you to insert a remote repository as a subdirectory in another repo.
GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY HOW TO
Thanks if you could take a moment to help me explore how to fix firehawk % git submodule add įatal: not a git repository: firehawk % cat ansible/.gitįatal: pathspec 'ansible' did not match any firehawk % rm -r firehawk % git submodule add įatal: not a git repository: /Users/user/git/firehawk-deploy-dev/firehawk/ansible/././.My-chart in the helmcharts repo is used in the operator repo as /helm-charts/my-chart so I tried to remove the created subfodler and try again, but it still didn't work. Running this command will create a new subdirectory called containing nothing but the. Upon adding the submodule I got an error: " not a git repository". Create an empty Git repository in the specified directory. In my case I ran into trouble on the last step and I'm not sure how to fix my repo now. Thanks for sharing this possible approach.
GIT ADD REMOTE REPOSITORY TO A SUBDIRECTORY PRO
Git commit -m 'replaced plugins/media with a submodule'įor more on submodules, see this chapter in the Pro Git book: Git submodule add url_to_repo plugins/media Most probably you want to replace the directory with the new project as a submodule: git rm -r plugins/media You can also set these remotes as your default push or pull locations, shortening. This way you'll be still able to push, which is not possible with git archive. Tested it myself only with 2.2.0 and 2.2.2. git/info/sparse-checkout git pull -depth1 origin master You'll need minimum git 1.9 for this to work. Make an initial commit because we need one before we do a merge.
The remote name is helpful for being able to reference this repository without having to type out the entire location. git initNote that the original repository is unchanged: Or locally: git init -bare /tmp/proj-media.gitĪnd push the media branch to the remote with the name `master: git remote add proj-media /tmp/proj-media.git Next, create the target repository, for example on GitHub, You can confirm the result with git log media. This will put all commits related to plugins/media in a new branch named media. Let's say you have a project with a sub-directory called plugins/media and you want that in an independent repository: git subtree split -P plugins/media -b media With only the commits that involved the specified sub-directory. Git has a nice command to make this easy called subtree split. Before pushing to the remote, you need to ensure the local override was. Would be better as an independent project. This requires the same attention as git submodules. Recently I realized that a sub-directory in a Git project
