1

I have a repo that consist of 4 directories. Each directory contain different part of the project

The 4 directory is : asset, backend, mobileapp, util

backend contain a nodejs project that act as a backend, the mobileapp will contain android and ios project

I want to push just the backend folder to a live repo (I want to push it to a App Service at Azure) without the other 3 directories...

How can I do that?

godot
  • 3,422
  • 6
  • 25
  • 42
Hari Anugrah
  • 484
  • 1
  • 7
  • 12

2 Answers2

1

The only thing you can push to a repo is a branch. If you want to push only one directory you need to create a branch or a separate repo with just that subdirectory.

See https://stackoverflow.com/a/359759/7976758 on how to detach a subdirectory into a separate Git repository.

phd
  • 82,685
  • 13
  • 120
  • 165
1

Here you can find detailed instruction how to do it. I recommend to create separate local clone of repo first since you will rewrite history.

The most important part is this command:

git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME  BRANCH-NAME 
Marek R
  • 32,568
  • 6
  • 55
  • 140