I have two version of a website that I ideally would like to sync with an existing Git repo. They are in two different physical directories on my local machine.
Is there a way I can add the contents of one folder to one branch and the other to a different branch?
To do this, set up a git repository in both directories with
git init
. Then, create a different branch in each directory withgit checkout -b branch-name
. Put whatever filespecs you wish into.gitignore
in both directories, thengit add
the appropriate files in each directory. Finally, add the same remote in both directories withgit remote
.git push
them both, and you will have a single repository with two branches, with two local directories, one mapped to each branch.Note that the first time you try merging these branches, you will get a lot of conflicts. That is because there is no base branch which these two branches sprung from, so git will have no idea of knowing which version of a file should be the "real" one.