]> rtime.felk.cvut.cz Git - hubacji1/oneflow.git/blob - branching.md
Extend explore branches section
[hubacji1/oneflow.git] / branching.md
1 # Branching
2 It's not a good idea to multitask when working. However, some projects just
3 need it. The reason can be multiple features you are developing in parallel or
4 more than one guy working on the project. To keep track of different changes
5 that are realated the concept of branches was introduced.
6
7 Branch is just alternative history that can be merged one day back to the main
8 history. The main history branch is named `master` by default.
9
10 # Explore branches
11 `git branch` command show all the local branches and the active branch you are
12 currently on. Show remote branches by `git branch --all` command.
13
14 # Split - create alternative branch
15 When decided to create new branch `git checkout -b NAME` can be used. Switching
16 between branches is done by `git checkout NAME` command.
17
18 # Merge - join multiple branches
19 To the current branch, any other branch may be merged. The result is history
20 that contains all commits in both branches. Command `git merge --no-ff NAME`
21 will merge the branch `NAME` to itself. `--no-ff` avoids melting the branch
22 being merged. It's hard to explain, better to show.
23
24 # Rebase - change the base commit of branch
25 Each branch start at some commit. This starting commit of the branch can be
26 also changed usually because of keeping clean history. The command `git rebase
27 COMMIT` takes current branch and put it on top of the `COMMIT`.
28
29 # Cheat sheet
30 ## Explore
31 - `git branch`
32 - `git branch --all`
33
34 ## Split
35 - `git checkout -b NAME`
36 - `git checkout -b NAME COMMIT`
37 - `git checkout NAME`
38
39 ## Merge
40 - `git merge --no-ff NAME`
41
42 ## Rebase
43 - `git rebase COMMIT`
44 - `git rebase -i COMMIT`