git directory structure confusion
Coming from an svn background, although not a that advanced user, I had a confusion on the directory structure of git.
For a C++ project, I read the first 3 chapters of the book pro git which is online. I guess that it is a pretty good book with lots of figures that ease explanations.
Now the question is that svn was creating a trunk directory under which my header and source codes were located namely(more precisely I was creating them with svn commands), the include and src directories. In the first 3 chapters an开发者_JAVA技巧d thereafter I did not see a structure like this. Question is that what is the best strategy to structure your work under directories like this, should create different directories and add the files under these directories separately to tracking control or is there a more structured way to do this as a whole?
I guess I do not have to keep everything in one place, which is highly unlikely...
You can use any folder structure you want.
If you want to have
myproject
|-- src
|-- include
that's fine. You do (of course) not have to keep everything in one place.
The only thing is that (assuming myproject
is your repo's root) you will have a .git
folder there where your repo data is stored:
myproject
|-- .git
|-- src
|-- include
Unlike the .svn
folders in every folder of an SVN working copy, Git uses only this one folder to keep track of the repo.
svn does not have any real tags and branches, everything is just a copy of another file or folder. git supports real branches and does not need a directory structure similar to svn.
simply create the directory structure required for your project – for branching and tagging use git branch
and git tag
respectively (as opposed to subversion's svn copy
command)
git makes a clear difference between the contents of a revision (files which are arranged in a directory tree) and the revision history and your branches.
So a typical git user would not create directories like trunk and branches. One commit really contains only the files belonging to this revision. It's all up to your contents, no git book will recommend what it has to look like.
To look at your history of revisions use the tool gitk.
Of course if you really want to, you can create directories trunk, branches etc.. git will not complain. SVN users might be happy to see such repo, git users probably not so much.
精彩评论