Home > Enterprise >  Is it possible to `git push` project to a certain folder in GitHub repository?
Is it possible to `git push` project to a certain folder in GitHub repository?

Time:04-12

I have a frontend and backend for my project. They both reside in two different folder locally, so they are completely separate. I want them to share the same GitHub repo though, for example, could the repo have 2 folders called frontend and backend that can be used to hold the appropriate code?

If so, what commands are used to push the source code from each project into the frontend or backend folders?

CodePudding user response:

This is a confused question but I will try to give you an answer.

If this is your structure:

  • my_project (repo)
    • frontend (folder)
    • backend (folder)

Then that is just an arbitrary folder tree in the my_project repo. Just commit and push as normal. It doesn't make any difference where the changes are made.

You could use git submodules. This would allow you to separate the projects

  • my_project (repo)
    • frontend (repo, submodule)
    • backend (repo, submodule)

my_project may contain environment or other generic configurations and each of the submodules are independent repositories. Changes in each are controlled separately but still with simple commit, push.

If you want to convert from folders to repositories then simply copy the folder out of the current git tree and run git init, then push it.

  • Related