/
day-1.txt
147 lines (104 loc) · 5.78 KB
/
day-1.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
== First Part
This part should introduce you to adding a new branch with Git, switching between the branches, and how to do the most basic work with Git.
The changes for the ICC learning project are currently located at SD2 repository, within the branch "icc_project"
This part assumes:
* You have already cloned SD2, if not look into http://www.scriptdev2.com/showthread.php?t=4
* You are on a clean branch, and have not yet used the name "icc_project" for a branch on your system.
See the next section how to check, and restore a clean environment
I will always use the Git bash to work with Git.
Hence I strongly suggest for you to use it as well.
But nearly all stuff must work with GUI tools somehow
(Note for *nix User: "Open 'Git bash here'" can be translated to open a bash in the directory)
So, to do anything with Git, we will open a Git bash in the ScriptDev2 directory in your MaNGOS source folder - in src\bindings\.
To do so, open your explorer, right click the "ScriptDev2" directory and select "Git bash here" from the context menu.
This will open a nice black and white window, where you can type commands in a very old fashioned way :)
=== Checking your status
The first and most important command is
--------------------------------
git status
--------------------------------
This will show the current state of your work tree related to the index.
What does this mean:
When you look at your ScriptDev2 directory, there are two things you must keep in mind:
* The directory contains files - these files are referred to as the work tree, and are just normal files.
* Git has an internal representation of the history related to your project, this history is stored in the index.
So +git status+ now shows you in which state every file in your work tree is in relation to what state the file should be compared to your current history index
The default output should be:
--------------------------------
# On branch master
nothing to commit (working directory clean)
--------------------------------
This shows you that you are on your "master" branch (this is default), and that you have no change related to your history (working directory clean)
[NOTE]
[icon="./images/icons/example.png", caption="Exercise"]
.*Exercise 1* - Check the status
==================================================================
Add or change a file, and compare the output of +git status+
==================================================================
If you have a not clean working tree, you must clean it.
=== Resetting your working tree to the index
[WARNING]
==================================================================
This will delete all changes!
--------------------------------
git reset --hard
--------------------------------
==================================================================
Note: This will only affect files which are known to the index, so a new created file won't get deleted.
Remark: This will only give you what I expect, if you didn't too many experiments yourself.
=== Updating your remote information for the SD2 repo.
The SD2 repo (assuming it was cloned from initially) should be named "origin"
If you have done nothing special, it will be and you don't have to worry.
To update the information for the remote origin repository, simply do:
--------------------------------
git fetch
--------------------------------
=== Cloning the remote branch containing the icc learning project.
Git is really great when it comes to branching.
This means, it is easy to have different branches of history-indexes and to switch the working-tree files between them.
The reason why branches are so cool is, that one branch does not change the history of another branch.
So it is very easy to have different things to work on.
The process to switch the working tree from one history branch to another is called "checkout", and hence the command that is to be used is
--------------------------------
git checkout <newBranch>
--------------------------------
where <newBranch> is the name of the branch to which you will switch your working tree
However, before you are able to checkout to a branch, you must create it.
To make this easier, there is the "-b" option for the checkout command:
All in all you should type:
--------------------------------
git checkout -b icc_project -t remotes/origin/icc_project
--------------------------------
This will do the following:
[horizontal]
*-b*:: create a new branch named "icc_project"
*-t*:: use the point from which you branch as "tracking" branch
*remotes/origin/icc_project*:: is the branch icc_project in the repository origin which is a remote repository
=== Switching between branches:
As already mentioned, you can easily switch between branches with
--------------------------------
git checkout <branchName>
--------------------------------
[NOTE]
[icon="./images/icons/example.png", caption="Exercise"]
.*Exercise 2* - Test switching
==================================================================
Observe changes of files in the directory (especially the sub directory icc_project) while switching with
--------------------------------
git checkout master
git checkout icc_project
--------------------------------
==================================================================
== End of First Part
=== What this part was about:
* Checking the status of working tree, command > git status
* Checking out a remote branch into a local branch
* Switching branches, command > git checkout
=== Most important concepts:
* index and working tree (What were they?)
* branches in Git (What are they used for?)
=== Additional resources:
TIP: http://www.youtube.com/watch?v=4XpnKHJAok8[Tech talk about what Git is not] This is a nice vid, it should clarify why we use git, and explain some more concepts of Git :)
=== What comes next:
* How to do local commits
* How to read history