slide1.md 1.33 KB
Newer Older
French, Robert's avatar
French, Robert committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Branches for Fun and Profit

## Organized Brainstorming

Branches allow you to organize your thoughts and make experimental changes in
an isolated environment. They also make it easy to throw bad ideas out the
window without tedious rewinding and backtracking.

### List current branches
```bash
git branch
```

This shows the branches that are already available in your project. You should
usually have at least one branch called `master` that represents a working
copy of your program.

### Create a new branch (try a new idea)
```bash
git checkout -b dandy-new-idea
```

Now we have a safe area where we can hack away on a new idea. If you want to
show some of this work to your colleagues, but are not yet ready to make it
part of your "production" application, you can push it to gitlab like so:

### Push to a remote branch
```bash
git push -u origin dandy-new-idea
```

This tells git to make a new *upstream* branch that you plan to keep in sync
with your local `dandy-new-idea` branch.

### Merge good ideas into master
```bash
git checkout master
git merge dandy-new-idea
```

Once you like your new code and **all your existing tests pass**, merging your
changes into the `master` branch signifies that your new work is good and ready
to be released into the wild (or at least, to be considered for release).

[previous](README.md) | [next](slide2.md)