Is there a naming convention for git repositories?

前端 未结 6 627
無奈伤痛
無奈伤痛 2021-01-29 17:23

For example, I have a RESTful service called Purchase Service. Should I name my repository:

  1. purchaserestservice
  2. purchase-rest-service
相关标签:
6条回答
  • 2021-01-29 17:49

    lowercase-with-hyphens is the style I most often see on GitHub.*

    lowercase_with_underscores is probably the second most popular style I see.

    The former is my preference because it saves keystrokes.

    * Anecdotal; I haven't collected any data.

    0 讨论(0)
  • 2021-01-29 17:55

    Without favouring any particular naming choice, remember that a git repo can be cloned into any root directory of your choice:

    git clone https://github.com/user/repo.git myDir
    

    Here repo.git would be cloned into the myDir directory.

    So even if your naming convention for a public repo ended up to be slightly incorrect, it would still be possible to fix it on the client side.

    That is why, in a distributed environment where any client can do whatever he/she wants, there isn't really a naming convention for Git repo.
    (except to reserve "xxx.git" for bare form of the repo 'xxx')
    There might be naming convention for REST service (similar to "Are there any naming convention guidelines for REST APIs?"), but that is a separate issue.

    0 讨论(0)
  • 2021-01-29 17:59

    I'd go for purchase-rest-service. Reasons:

    1. What is "pur chase rests ervice"? Long, concatenated words are hard to understand. I know, I'm German. "Donaudampfschifffahrtskapitänspatentausfüllungsassistentenausschreibungsstellenbewerbung."

    2. "_" is harder to type than "-"

    0 讨论(0)
  • 2021-01-29 18:05

    The problem with camel case is that there are often different interpretations of words - for example, checkinService vs checkInService. Going along with Aaron's answer, it is difficult with auto-completion if you have many similarly named repos to have to constantly check if the person who created the repo you care about used a certain breakdown of the upper and lower cases. avoid upper case.

    His point about dashes is also well-advised.

    1. use lower case.
    2. use dashes.
    3. be specific. you may find you have to differentiate between similar ideas later - ie use purchase-rest-service instead of service or rest-service.
    4. be consistent. consider usage from the various GIT vendors - how do you want your repositories to be sorted/grouped?
    0 讨论(0)
  • 2021-01-29 18:05

    Maybe it is just my Java and C background showing, but I prefer CamelCase (CapCase) over punctuation in the name. My workgroup uses such names, probably to match the names of the app or service the repository contains.

    0 讨论(0)
  • 2021-01-29 18:07

    If you plan to create a PHP package you most likely want to put in on Packagist to make it available for other with composer. Composer has the as naming-convention to use vendorname/package-name-is-lowercase-with-hyphens.

    If you plan to create a JS package you probably want to use npm. One of their naming conventions is to not permit upper case letters in the middle of your package name.

    Therefore, I would recommend for PHP and JS packages to use lowercase-with-hyphens and name your packages in composer or npm identically to your package on GitHub.

    0 讨论(0)
提交回复
热议问题