Juan Palacios Plaza
Juan Palacios Plaza

Reputation: 109

How to turn an existing, non-empty directory into a git branch of an existing non-empty git repo living in another directory

I have two directories, A & B, which differ very little in their content. A is already init'd into a git repo and has a number of local commits to its master branch. Directory B is not under SCM and it's basically just the result of manually copying all the files over from A (sans the .git directory), editing some of them, and adding some new ones. Now I want to make the contents of B a branch of the repo in A and, if possible, still host development of the new branch in directory B... but I have no idea how to accomplish that as I am a total git n00b, and don't quite yet understand its approach to SCM enough to find the answer on my own in the documentation. Any tips/pointers? Thanks in advance!

Upvotes: 3

Views: 2131

Answers (1)

romaninsh
romaninsh

Reputation: 10664

copy A/.git into B/.git. Then do what you normally would do for the branching.

cd B
git branch dev
git commit -a

You can then sync changes like this:

cd A
git pull ../B dev

or the other way around.

Upvotes: 3

Related Questions