HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
      • Create new note
      • Create a note from template
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Save as template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
      • ODF (Beta)
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
    Menu Sharing Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML ODF (Beta)
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # FreeBSD Git Questions/Concerns ## Background This Q&A document is intended to (collect and) answer common questions that come up in the context of the FreeBSD Git Working Group's investigation into workflow and process changes that would be involved in a migration to Git as the canonical repository for FreeBSD (src, doc, and ports). Nothing in here is intended to be perscriptive (i.e., describing decisions that have been made), but rather avoid having the same questions and responses be brought up multiple times on various mailing lists. Ed Maste wrote most of this document, with input from several others. Please feel free to add comments on this hacmkd document (by clicking on the 💬 to the right of a paragraph), or email either the freebsd-git@ mailing list or emaste@ with comments, questions or concerns. ## What's wrong with Subversion? Subversion has served FreeBSD well, and the Subversion developers have been good to the FreeBSD project (with respect to maintenance, implementing valuable features, etc.). That said, today FreeBSD downstream consumers and general open source contributors almost universally use git, as do a sizeable fraction of FreeBSD committers. Having to learn an unfamiliar version control system and different processes is an additional hurdle for today's new developers. (Of course a similar argument can be made about existing FreeBSD developers already familiar with Subversion, having to learn Git -- but the group of developers new to FreeBSD grows over time.) The current [svn→git GitHub mirror](https://github.com/freebsd/freebsd) works well enough but imposes additional hurdles for bringing work developed in Git back into the canonical Subversion repository and precludes the use of Git for certain operations (such as MFCs and vendor source updates). These operations can be performed only by Subversion committers. Also, as LLVM developers pointed out in their own Subversion to Git migration plan, many tools are being built on top of git with support for other version control systems added later, or poorly, or not at all. Finally, Subversion can be very slow depending on the operation being performed and the state of the network between the developer and the repository. ## I heard Git is not a Version Control System. How then could we use it? This argument is misplaced. The question should not be whether or not git fits into the traditional VCS box, but rather whether it meets the project's requirements in creating reproducible releases and keeping running history of the major lines of development. Git can do those things, in addition to allowing easier and more productive collaboration. Finally, notions of what is or is not an acceptable list of features for a VCS has evolved over time. git and other DVCS have caused a sea change in thinking in this area. A specific feature of git that's often cited is its ability to rewrite history without metadata to record those details (you can't easily see the "actual" history of a branch). This is mitigated in two ways: the source of truth repo can refuse to accept these changes. Second, git actually does keep recent history of branches (via reflog). It will not preserve that history, though, as in a git world these changes are intended to be used to refine bodies of work that's submitted elsewhere. The history of changes is more logical than physical as changes curated in this way are often logical changes. The mechanics of how the logical changes were created is viewed as an uninteresting detail. ## What's with the funny revision hashes? I want revision numbers. Revision hashes are a detail of Git's implementation that's exposed to the end user. They are a unique identification of the tree's file content and metadata and the history that lead to that state. Revision numbers can be simulated via `git rev-list --count HEAD`, which counts the number of commits since the initial commit. This is calculated at run time, so is not instantaneous. `rev-list --count` is relative to the branch (not repo-wide) and so is not unique across branches. The tuple *(branch, rev-list count)* is unique, and is consistent between clones. There's a [Phabricator review](https://reviews.freebsd.org/D20462) open for adding this count to uname. This is an area under active development in Git; see for example this [Microsoft blog post on Generations and Graph Algorithms](https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph-iii-generations/). With a little work we could implement a Git front-end command to immediately report a suitable proxy for the revision number. ## Are Git clones large (on-disk)? Because a git clone includes all history (by default) it is somewhat larger than a Subversion checkout (which by default includes an unmodified copy of every file). That said, the difference is minimal. Ed gave a Git status update at MeetBSD 2018, and reported the following results: | VCS | Total Size | .git/.svn size | | --- | ---------- | -------------- | | Git | 3.9GB | 2.3GB | | SVN | 3.3GB | 1.6GB | With defaults for both cases the Git clone was a little under 20% larger than the Subversion checkout. Git also supports multiple *worktree*s sharing the same *.git* directory, so a developer with two working trees could actually achieve a disk space savings of a little under 20% with Git. Developers with many working trees will see greater savings. ## Do I have to have all of the history locally? No. Git supports *shallow clones* which include a configurable amount of history. Ed tested this with git version 2.21.0. A shallow clone can be created with `git clone --depth 1`. Commit hashes are maintained (i.e., are the same as a full clone), and `git push` works. It is possible to combine shallow cloning with a clone of a single branch, for an even smaller clone: `git clone -b <branch> --depth 1`. **TODO:** What does `git rev-list HEAD --count` show for a shallow clone? ## What about `$FreeBSD$` tags? Git does not support expansion of `$` tags (`$Id$`, `$FreeBSD$`, `$Date$` etc.) on the server. It does support [keyword expansion](https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes) on the client side, expanding them on checkout and squasing them upon commit. Because the support is implemented client-side and is optional we would likely need to deprecate their use - allowing individual developers to have them expanded locally, but not require them to be expanded for standard processes (such as release engineering). It's a policy question for when or if we exapnd the keywords, not a tools question. Having the expansion optionally happen on checkout means that the problems with diff collisions which are seen with svn are not seen with git. ## If we move to git can we still have commit mail? Yes. Commit mail can be generated with a commit hook, as with Subversion. The exact approach taken would vary depending on the hosting model. ## Does git have an appropriate license? The standard Git client is licensed under the GNU General Public License, v2 (GPLv2). Various Git libraries and other implementations exist under a variety of copyfree, copyleft, and proprietary licenses. [Game Of Trees](http://gameoftrees.org/) is a copyfree VCS from some OpenBSD developers. It is compatible with Git repos and is now in the FreeBSD ports tree [OpenGit](https://github.com/khanzf/opengit) shows promise as a BSDL tool, but is a very early work in progress and has not been updated recently. [go-git](https://github.com/src-d/go-git) needs a simple 3-line wrapper to be sufficient to support cloning ports tree. ## Can I check out only part of the tree? [Partial Clone](https://www.git-scm.com/docs/partial-clone) support is in progress. A partial clone should be possible via a command like `git clone <URL> --filter=sparse:path=/bin/ls freebsd-bin-ls`, but note that it requires server-side support which is generally not yet available. ## Have other projects migrated from Subversion to Git? Many projects have made the transition, and FreeBSD is currently one of very few large, well-established and active open source projects using Subversion. See the [LLVM project's Git transition](https://llvm.org/docs/Proposals/GitHubMove.html) for a detailed example of a Git migration in a project with broadly similar size, rate of change, history, and community. There's a Doctor Dobb's articles on [Atlasian's](http://www.drdobbs.com/architecture-and-design/migrating-from-subversion-to-git-and-the/240009175) move from subversion to git. Many of Apache's project have migrated to git, for example [Maven](https://cwiki.apache.org/confluence/display/MAVEN/Git+Migration). In addition to these specific examples, a google search shows dozens (if not hundreds) of projects that have migrated to git over the past 15 years. Many of these projects are open source. ## Does Git mandate a Linux-style hierarchical model? No. Linux's work flow is but one of many ways to use git. ## Does Git track file renames and copies? Not really; renames, copies and moves are inferred as necessary (e.g. in `git log`). We must determine how much of an issue this is in practice, which may have a different answer for different repositories (src vs doc vs ports). ## What is the recommended workflow to develop with Git? Good question! There are multiple approaches we could take with a migration to Git, and one of the working group's tasks is to evaluate (prototype/test) several approaches and make a recommendation. One of the explicit tasks of the working group is to ensure that the random problems from unrestrained git usage are avoided by the workflow, or the pitfalls are documented to allow proper tradeoffs to be made depending on the situation. Like was done with the Subversion migration, a git primer will be created. Like the developer's guide article on Subversion, it will document how to use git in FreeBSD's work flow. ## Can Git help me find out where a bug/regression/panic was introduced? Yes, see the [git bisect](https://git-scm.com/docs/git-bisect) command. It can be used to choose and check out revisions for the binary search (leaving the build and test to the user), or can operate fully automatically (with a scripted build and test). It is also able to bisect only changes that affect a subtree (e.g., bisecting only changes that touch files under *sys/* if looking for a kernel regression). # Please add new questions below ## Use H2 (##) for the questions ## What about checkout by date? ## Any requirements on minimal git version?

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in via Google

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully