Reputation: 2415
So I cloned this code from repository A, and made a subfolder B inside the code. All my work is done in the subfolder, and I want to put the subfolder under version control, but I never want to push changes in B to repository A. In fact I don't think I even have push access to repository A. How can I put subfolder B into repository B?
I heard about submodules but I'm getting errors when I try to use them: (I'm in subfolder B right now)
user@host:~/code$ git init
Initialized empty Git repository in /pathtosubfolder/code/.git/
user@host:~/code$ git submodule add .
repo URL: '.' must be absolute or begin with ./|../
user@host:~/code$ git submodule add ./
fatal: could not create work tree dir ''.: No such file or directory
Clone of '/pathtosubfolder/code/' into submodule path '' failed
user@host:~/code$ git submodule status
user@host:~/code$ rm -rf .git
user@host:~/code$ git submodule init
You need to run this command from the toplevel of the working tree.
Thanks!
Upvotes: 2
Views: 2119
Reputation: 2622
In your A project folder do:
git submodule add git://repo-b-path.git codes
You must work with "submodule" command in your A repo
Upvotes: 4