-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxbdb.txt
45 lines (45 loc) · 2 KB
/
xbdb.txt
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
Branching
This is the fun part of Git that you’ll come to love like a child.
When you first initialize a git repository,
or clone one,
you’ll get a ‘master’ branch by default if you don’t specify something else.
This is really just a git suggestion
and you don’t have to use it
– like just about everything in Git,
it can be overridden.
Switching Branches
However,
let’s say we’re working on our project and we want to add a new function to our library,
so we’ll make a new branch called ‘new- func’ and switch to it.
There are two ways we can do this,
one is to create the branch and then switch to it:
$ git branch newfunc; git checkout newfunc
The other way is to checkout a branch that doesn’t exist yet
and tell git you want to create it by passing the ‘-b’ flag:
$ git checkout -b newfunc
Now, to check which branch we are on,
we just type ‘git branch’:
We can see we are now on our new branch.
This means that if we modify a file and commit it,
this branch will include that change,
but the ‘master’ branch will not have it yet.
So, we add a new method to our library and commit it.
Now we want to change something in the README in the ‘master’ branch,
but we haven’t tested this function yet so we don’t want to merge our new branch in yet.
That’s fine, we just switch back and make the change.
Now lets see what the differences in our branches are.
We could also get a patch file for one to apply to the other,
but what we really want to do next is merge the two.
• git branch (http://www.kernel.org/pub/software/scm/git/docs/git-branch.html)
• git checkout (http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html)
branching and merging screencast
In this screencast,
we take you through a workflow where we branch,
stash and merge several times.
It demonstrates the branch and show-branch commands,
how to switch branches,
how to stash changes,
how to list and apply stashes,
how to resolve conflicts,
how to create and delete topic branches,
and what fast-for-ward merges are.