Search code examples
gitgithubgit-submodulesgit-mergefork

Git submodule pull request work flow


I am curious about some best practices.

There is a git repo that I would like to include as a submodule in my project. I would also like to contribute to this repo and offer pull requests. I have forked the repo and would like to add my fork as the submodule to my project.

I have made a new slim branch in my fork that removes some stuff from the original repo master branch: e.g. example files, demos, etc. I would specifically like to use this slim branch for the submodule to keep the extra stuff out.

I have successfully done this branching and submodule strategy. However I am now wondering about pull requests and contributions to the project.

Ideally I would like to edit the submodule as part of my project, and push commits to the submodules slim branch. I would then like to merge the changes in slim branch back into master so that I can do a pull request.

However I do not want my initial delete commit on the slim branch to be merged back into master. What are some ways I can contribute back to the project with out messing in some of my delete commits?


Solution

  • When you want to make a change, create a feature branch from slim to do your development. Then when you want to contribute it, run:

    git rebase --onto master slim feature
    

    That will make it look like feature was branched directly from master without any of your deletions in slim.