美文网首页
《Git Succinctly》读书笔记

《Git Succinctly》读书笔记

作者: orit | 来源:发表于2015-01-31 10:57 被阅读66次
    《Git Succinctly》封面

    作为一个SVN的多年用户,切换至Git后,一直不是很适应,对于Git很多概念只是粗略的了解。虽然读过不少介绍Git的书,但没有越看越清晰的感觉。直到遇到了《Git Succinctly》这本书,虽然只有短短的59页,但是讲解的非常到位,而且介绍了一些Git的习惯用法,比如分支的用法,以及合作开发模式,非常实用。

    摘录

    • The first thing you’ll want to do with any new Git installation is introduce yourself. Git records this information with your commits, and third-party services like GitHub use it to identify you.

      git config --global user.name "John Smith"
      git config --global user.email john@example.com
      

      The --global flag records options in ~/.gitconfig, making it the default for all new repositories.

    • This also gives us a natural grouping of commands:

      • Stage/Working Directory: git add, git rm, git status
      • Committed History: git commit, git log
    • In addition to completely undoing commits, you can also amend the most recent commit by staging changes as usual, then running:

      git commit –amend
      

      This replaces the previous commit instead of creating a new one, which is very useful if you forgot to add a file or two.

    • With this in mind, it’s usually a good idea to have a clean working directory before checking out a branch. A clean directory exists when there are no uncommitted changes. If this isn’t the case, git checkout has the potential to overwrite your modifications.

    • The two most common merge methodologies are:

      • The “fast-forward” merge
      • The “3-way” merge

      They both use the same command, git merge, but the method is automatically determined based on the structure of your history. In each case, the branch you want to merge into must be checked out, and the target branch will remain unchanged.

    • It’s often useful to assign special meaning to different branches for the sake of organizing a project. This section introduces the most common types of branches, but keep in mind these distinctions are purely superficial—to Git, a branch is a branch.

    • Like merging, git rebase requires the branch to be checked out and takes the new base as an argument:

      git checkout some-feature
      git rebase master
      

      This moves the entire some-feature branch onto the tip of master.

    • never rebase a branch that has been pushed to a public repository.

    • Git accepts many network protocols for specifying the location of a remote repository, including file://, ssh://, http://, and its custom git:// protocol.

    • The two most common collaboration models are: the centralized workflow and the integrator workflow.

    • it’s not a silver bullet for project management. It is merely a tool for tracking your files, and no amount of intimate Git knowledge can make up for a haphazard set of conventions within a development team.

    相关文章

      网友评论

          本文标题:《Git Succinctly》读书笔记

          本文链接:https://www.haomeiwen.com/subject/opvlxttx.html