Changes between Version 10 and Version 11 of GitMigrationProposal

Show
Ignore:
Timestamp:
03/15/09 07:15:05 (4 years ago)
Author:
cdavid
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitMigrationProposal

    v10 v11  
    127127 
    128128TODO: handling of remote locations. 
     129 
     130= A first few git specific workflows = 
     131 
     132== The branch concept == 
     133 
     134Git, like other DVCS, is strongly designed around the notion of branches. Instead of everyone committing directly to the trunk, most development happen in branches, which are then merged into the trunk. What's the point, you may ask ? 
     135 
     136 * commit is fast: it is instantaneous. 
     137 * branches are isolated: if you work on a non trivial feature, having a separate branch means you can commit regularly on it, without pushing things into the "trunk". In particular, you can break things without disturbing anyone else. 
     138 * branches are a useful unit of decomposition. Although it still certainly makes sense to commit things directly into the main line of development, regularly using separate branches is a good way to split tasks. This is especially useful for reviews: having a separate branch means everyone can easily look at those changes only. The examples will obviously make this clearer. 
     139 
     140== Scenario 1: creating a new branch == 
     141 
     142Creating a new branch to make my changes. 
     143 
     144{{{ 
     145# Create a branch from an old branch named oldbranch 
     146git branch newbranch oldbranch 
     147# Switch to the new branch 
     148git checkout newbranch 
     149}}} 
     150 
     151This can be done in one command: 
     152 
     153{{{ 
     154git co -b newbranch oldbranch 
     155}}} 
     156 
     157Now, every commit will happen in the newbranch. Again, as for commits, the branch is only created in your repository, and not propagated to the repository, unless you explicitly push for it: 
     158 
     159{{{ 
     160# This push all the changes in newbranch onto the remote repository 
     161git push url_repo newbranch 
     162}}} 
     163 
     164== Scenario 2: comparing branches == 
     165 
     166This is one example where git is much more powerful AND easier than svn :) To compare HEAD of two branches (that is the last revision of each branch), you simply use the branch1..branch2 syntax: 
     167 
     168{{{ 
     169# Get the diff "between" two branches 
     170git diff oldbranch newbranch 
     171# Get the log of commits "between" two branches 
     172git log oldbranch newbranch 
     173}}} 
     174 
     175We use "between" very loosely. For the simple following scenario: 
     176 
     177 
     178   - o -- o -- o oldbranch 
     179      \ -- o -- o newbranch 
     180 
     181Where o is one commit, the above commands will give you the commits specific to newbranch AND the commits from oldbranch since newbranch was started. To get only the changes related to the commit *specific* to new branch, use the ... syntax instead: 
     182 
     183{{{ 
     184git diff oldbranch...newbranch 
     185git log oldbranch...newbranch 
     186}}} 
     187 
     188Note the difference between '..' and '...'. '..' (2 dots) is the same as a space. 
    129189 
    130190= Rationale for git =