6

I'm trying to use Git on my local Windows machine only. I have an existing project that I want to move into Git. I'm not quite sure how I should structure the workflow. Should I make that existing project folder the main repo for my project and then create other branches off of that? Or should I create one central location for all Git repos, copy my existing project files there as the main repo, then just check out my project from the central repo into a new folder?

A similarly worded question would be, should there be one central Git folder where all of your repos live or should there be main repos (trunks?) scattered around per project?

I guess this question only makes sense when running and using Git locally. When using it against a true remote repo, then it seems to makes more sense.

traughber
  • 133
  • 2
  • 6

1 Answers1

10

You can directly create your Git repo within the folder of your main project.
They will be added by default in the master branch.
(cd c:\path\to\yout\project && git init . && git add . && git commit -m "first commit")

No need for a "central" folder where all your git repos should live.
Each Git repo can evolve directly where each project is.

BarrowWight
  • 181
  • 2
  • 12
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Perfect. Thank you very much. I have a different but related question. If it should be in a separate post, let me know and I'l do so. My buddy and I are working on a project together. We have a Bluehost account where we're going to install Git and keep our master repo for the project. But, we had already started working on the project before we decided to use Git (or any other VCS). Now, each of has different parts of the project on our own computers. How would we combine all that into one master repo on the host? Just upload it all to the host and add the repo to that folder? – traughber Aug 22 '12 at 23:16
  • @traughber yes, you can combine it, then start the repo, and clone it back to your local computers. If you start 2 separate repos, then you would have to do a subtree merge, which is more complicated: see http://stackoverflow.com/a/1426163/6309 (also https://help.github.com/articles/working-with-subtree-merge or http://git-scm.com/book/ch6-7.html). This script (http://stackoverflow.com/a/1761565/6309) could help, but again: grouping your 2 projects first, then starting the git repo is much more simple. – VonC Aug 23 '12 at 03:58
  • Thanks again. You've been a big help. – traughber Aug 23 '12 at 22:19
  • I have one more question regarding using Git only my local machine for solo projects. If I create a repo from an existing directory of files, I'm not sure I understand when I should be working on files directly in the main trunk versus when I should be creating a branch. I understand branching is good for creating/experimenting with a new version of your project, but should I be working off a branch from the beginning instead of working off the main trunk files? – traughber Aug 24 '12 at 11:56
  • @traughber branching is for isolating a development effort: see "When should I branch": http://stackoverflow.com/questions/2100829/when-should-you-branch/2107672#2107672 So it depends on how you see '`master`': if you have only one main development effort, and see master as 'the latest dev', keep on `master`. See another example here: http://stackoverflow.com/questions/7731900/what-does-the-refresh-branch-mean-what-does-next-mean/7732219#7732219 or here: http://stackoverflow.com/questions/7174312/can-i-merge-a-branch-into-an-old-commit-and-preserve-a-tag/7174334#7174334 – VonC Aug 24 '12 at 12:15
  • Thanks. When I branch, should I create the new folder as a sub folder under the master project or should I go out one level and create a sibling folder? – traughber Aug 24 '12 at 15:57
  • @traughber no need for directories! Branches are first-class citizen in Git: see http://stackoverflow.com/questions/5101270/git-store-branches-in-separate-local-directories/5101286#5101286 and http://stackoverflow.com/questions/1655235/pros-and-cons-of-different-branching-models-in-dvcs/1658599#1658599 . You can stay within the main root directory of your project and switch between branches: the content (of that same unique root directory of your project) will be updated accordingly. – VonC Aug 24 '12 at 17:04
  • I just figured that out. I'm using the Git support available in Netbeans and it works great. I just created a branch and it magically allowed me to switch back and forth from the master and the branch all without extra folders. Thanks again for all your help @VonC. – traughber Aug 24 '12 at 18:15