ソースを参照

Added up to chapter 3.5

Tomi Cvetic 8 年 前
コミット
35f3d52ea7
2 ファイル変更48 行追加0 行削除
  1. 1 0
      Git/ch3.1-branches
  2. 47 0
      Git/git-book.md

+ 1 - 0
Git/ch3.1-branches

@@ -0,0 +1 @@
+Subproject commit 3ca3dffb727d284c3a72f77142e218b11b07e08d

+ 47 - 0
Git/git-book.md

@@ -190,3 +190,50 @@ $ git tag -a v1.2 a6b4c9
 
 ## Chapter 3: Git Branches
 
+### What are branches
+* When committing, git stores an object with:
+  - pointer to the snapshot of the content you staged
+  - authors name and email
+  - the message you typed
+  - pointers to the commit(s) that directly came before this commit (parents)
+    * zero parents for initial commit
+    * one parent for normal commits
+    * multiple parents for merges
+* Therefore, in git a branch is a lightweight pointer to one of these commits
+* The default branch name is `master`
+
+### Working with branches
+* Creating a new branch `$ git branch testing`
+  - creates a new pointer to the same commit
+* HEAD is a special pointer that points at the commit you're currently on
+* Switch branches `$ git checkout testing`
+  - This moves the HEAD cursor to testing
+* Creating a branch is lightweight (writing the 40byte hash + a newline to a file)
+* Shorthand for branching and switching `$ git checkout -b testing`
+* Switching is not allowed, if there are uncommitted changes in a branch
+
+### Basic merging
+* Merge another branch into the current one: `$ git merge testing`
+* If a file was edited in more than one branch, a conflict will result and needs to be resolved before the next checkin.
+* you can manually resolve the conflict or use `$ git mergetool`
+* After the resolution, you can commit the changes.
+
+### Branch management
+* `$ git branch` gives a list of current branches.
+* `$ git branch -v` gives the same list, but with the latest commit messages.
+* To see what branches are already merged, use `$ git branch --merged`
+* To see what branches that haven't been merged yet, use `$ git branch --un-merged`
+* Deleting branches that haven't been merged fails.
+
+### Branching workflows
+1. Long running branches
+  * Used like different levels of hierarchy
+  * Basically one long linear line of commits, branches used as tags.
+  * Can be used to achieve different levels of stability
+1. Topic branches
+  * Branches diverge at any point
+  * allows to context-switch quickly
+  * can keep different parts of development isolated for longer times
+  * more challenging to merge.
+
+