简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM