Let's say I'm using git locally only, for web work in JavaScript. I've got git set up in just the base folder of the entire site, and I work on several features within that site (a rotating carousel, Ajax page loader, popup menus, etc). I obviously can't set things up into individual folders due to the structure (various scripts are in js/, images are in img/). What would be a good, clean way to work with git rather than just working on different features in one single repository? I was thinking maybe create branches called carousel, popup-menu, ajax-loader, etc., and just work on those specific features there, and merge them into the master. Does that make the most sense in this scenar开发者_Python百科io, where you don't have compartmentalized projects as you would for, say, a C++ application or Xcode project?
Additional question: does it make sense to put any unrelated files in .gitignore as well, then just list the files I'm working on as exceptions? e.g.:
*.html
*.php
*.jpg
*.js
*.css
!my-script.js
!another-file.css
I was thinking maybe create branches called carousel, popup-menu, ajax-loader, etc., and just work on those specific features there, and merge them into the master. Does that make the most sense in this scenario, where you don't have compartmentalized projects as you would for, say, a C++ application or Xcode project?
If you are both a coder and a designer I would recommend having separate branches for JS development, PHP coding and HTML stuff. For example, you can take a look at Git's branches: https://github.com/git/git/branches.
Additional question: does it make sense to put any unrelated files in .gitignore as well, then just list the files I'm working on as exceptions? e.g.:
What do you mean "unrelated files"? If those files are in your repository, they are related to your project.
Your .gitignore files can exist in the subdirectories where their entries make sense. There is no need to have one master .gitignore that would take care of everything. Your branching strategy seems fine. You'll be amazed at how many workflows git supports.
Hope this helps.
精彩评论