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
  • 2,792
  • 6
  • 21
  • 41
Hari Anugrah
  • 424
  • 7
  • 10

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
  • 69,888
  • 11
  • 97
  • 133
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
  • 27,988
  • 5
  • 42
  • 123