Wrote the README_GIT file to be a proper tutorial on git, repo.or.cz and gtkD.
[gtkD.git] / gtkD / README_GIT
blob72847b4cddba374466d8951990f1a81c96c5ecc6
1 _A short tutorial on git, repo.or.cz and gtkD_
3 Disclaimer: I really don't know how to use git yet, but this will give
4 you a start, as all the other tutorials are not so good.
7 Install git (1.5 or newer).
9 First you should set your user name and info with:
10         
11                 git config --global user.name "Your Name Comes Here"
12                 git config --global user.email you@yourdomain.example.com
13         
16 _Changing the default commit message editor_
18 Open /home/youruser/.profile with a text editor.
19 Add the line
20         
21                 GIT_EDITOR=/usr/bin/nano
22         
23 When you commit stuff with git, you'll automatically have to write a 
24 commit message with a text editor. The default is some wierd editor
25 without any info on how to use it, so that was a big hurdle on my way
26 to know how to use git. Now I'm using nano which is a commandline based 
27 editor, but with a clear UI. You propably could use any text editor 
28 like gedit or whatever. But nano is good, as it starts fast 
29 and you only need to write your commit message, and do CTRL-O to save 
30 it and CTRL-X to quit nano.
33 _Pulling from repo.or.cz_
35 Go to your favorite programming directory on the command line and:
36         
37                 mkdir gtkD
38                 cd gtkD
39                 git clone git://repo.or.cz/gtkD.git
40         
41 There's an awful lot of subdirs named gtkD at the moment, so excuse me 
42 for those. Not my fault entirely.
44 Go to the first subdir gtkD. And write:
45         
46                 git branch
47         
48 It will give you output like:
49         * master
50 Where the star will tell you which branch you're on, and there will 
51 only be one branch called master listed initially. If you'd have more, 
52 all their names would be listed.
54 With
55                 ls -a
56 you'll see, that there's a subdir called .git. That has your whole
57 local repository and settings. (If you want to dig more into that
58 you should check some other online manual on git. The interesting file
59 to me has been .git/config which has the settings of this git repo.)
61 To see what remote branches there are (in repo.or.cz), you can do
62         
63                 git branch -r
64         
65 That will show you something like:
66         origin/HEAD
67         origin/master
68         origin/mob
70 We're now interested in the mob branch. It's a special branch that is 
71 specific to repo.or.cz. They've made it so that if a project has a 
72 branch named mob, any user with the name mob can push their changes to 
73 that special branch. It will basically allow anonymous access, and 
74 therefore you should always be careful when executing code from the 
75 mob branch, as there could be just anything there. But if all goes 
76 well, it will serve as a kind of wikilike method for anyone to 
77 participate on the public repository, without asking me to give them 
78 permission. (You're ofcourse welcome to ask me, and I'll add your user 
79 that you've created on repo.or.cz to the list of people allowed to do
80 changes on the whole repo, if you want.)
82 So. How do we get a copy of that mob branch? Do:
84                 git checkout origin/mob
85                 git checkout -b yourlocalmob_name_it_anything_you_like
87 The first command will change you to the origin/mob branch, which is
88 the remote branch called mob in repo.or.cz (Got it?). Since we're in
89 that branch, the second command will create a new local branch with
90 the given name. So now you've created a local copy of the remote mob
91 branch and you've moved to that new branch.
94 _Making your own local branch_
96 Now you could make a new branch for your own development. It will be 
97 based on the localmob branch as that's where you're now. (This will 
98 basically replace the files you're working on, if you've done some 
99 changes and haven't run git commit -a.)
101                 git checkout -b yourbranchname
105                 git branch yourbranchname
106                 git checkout yourbranchname
109 Now you can see what branches you've got and where you're at with
110                 git branch
112 Create a file with some text editor. For example yourfile.d
113 Add it to your branch (so that git will track it).
115                 git add yourfile.d
117 You'll have to commit it to your new local branch. Otherwise it will 
118 get lost when you change branches. 
120                 git add yourfile.d
122 At anytime you can do
124                 git status
126 to see what you're currently doing, and haven't yet committed. 
127 (Committing means committing to your local repository, which is 
128 basically the directory "gtkD/.git/". If you put something into the 
129 internet (remote) repositories, that is called pushing.) So let's 
130 commit this. You'd better commit your changes before changing
131 branches as otherwise you'll just get confused with "staging".
132 And we won't go into that here, so just do:
134                 git commit -a
136 If you replaced your git editor as I told you in the beginning, you're 
137 represented with a nano screen (or the text editor of your choise). 
138 Write some description of what you did and why. It can be long and 
139 multiline if you want it to be, or if you've done a lot of changes. In 
140 nano you can then do CTRL-O to save it. Press ENTER to confirm the 
141 writing on the file that it suggests. And CTRL-X to quit nano. Then it 
142 will make the changes to your current branch.
144                 git status
146 will tell you that there's no more changes. It will also tell you in 
147 red if you have files that are not tracked by git. You can have such 
148 files, you don't need to add all stuff into git. Those untracked files 
149 will stay unchanged when changing branches.
151 Make changes to a file or many files. Run
152                 git status
153 to see some brief info on what you've done. And you can do
154                 git diff
156                 git diff --cached
157                 
158 to see some more info. (Press Q to quit that strange viewer.)
160 Commit it with
162                 git commit -a
164 and type in the commit message.
166 You can use
167                 gitk
168         
169 if you've installed gitk. It's a small app to visually see what you've 
170 done, and what branches you've got and how they were merged.
172 You could now delete that silly file called yourfile.d with:
174                 git rm yourfile.d
176 and do a commit on that too:
177                 git commit -a
179          
180 _Merging your changes to your local master branch_
182 After you've committed all your changes switch to e.g. the master 
183 branch with
184         
185                 git checkout master
186         
187 Then merge the yourbranchname branch with your master
189                 git merge yourbranchname
191 I'm not going to cover problems here, so let's just assume that the 
192 merge was easy and went fine. If you didn't make any changes to master 
193 after making changes to your yourbranchname branch then it should be 
194 fine. If you'd have done some little feature with your yourbranchname 
195 branch then you might not need it anymore, and could just get rid of it
196 with (this will lose your code if it's not merged to some other
197 branch):
198         
199                 git branch -D mob
200         
201 Or there's
202         
203                 git branch -d mob
204         
205 which will make sure you've merged it to current branch before deleting.
207 Branches in git are cheap. You should branch often, but don't make it 
208 too complex for yourself. You could always have a development branch.
209 When you've got that in good shape, and want to start on a new feature,
210 just create a new branch, and work on that. Once you're satisfied with 
211 it, commit, change to the development branch (or some other), merge, 
212 and delete the branch. You could have multiple branches where you 
213 develop many features at the same time. Then you could make a branch 
214 just for merging them, and if that works ok, you could merge
215 it to your development or even your master.
217 You should test all this stuff a few times to get a hang of it. You
218 can then always start over in another dir (or there might be some
219 git command to do it for you) with git clone git://repo.or.cz/gtkD.git.
220 And when you've got some good or bad changes you could go into the
221 next level and push your changes to the remote mob branch. Please
222 do that if you've got any changes that you'd think others could
223 benefit from. There will always be the history of all the pushes,
224 so your changes can easily be undone, if needed.
227 _Pushing your changes to the remote mob branch in repo.or.cz_
229                 git push ssh://mob@repo.or.cz/srv/git/gtkD.git yourbranchname:mob
231 Will do it. yourbranchname:mob means 
232 localsourcebranch:remotedestinationbranch. So if you'd have permissions
233 you could write to other remote branches as well. Currently there's
234 just master and mob. The mob@ is the username. If you've got a user in
235 repo.or.cz and I've given you permissions, you could just replace that
236 with your username. (And ultimately you could edit your .git/config 
237 file and add your user name there in the ssh:// line, but I won't go 
238 into that here.)
241 Further reading:
242 http://www.kernel.org/pub/software/scm/git/docs/user-manual.html
243 http://www.kernel.org/pub/software/scm/git/docs/tutorial.html