From 50fea17131017c8cac9bbab64bdfffacb51db0eb Mon Sep 17 00:00:00 2001 From: Jonas Kivi Date: Thu, 29 Nov 2007 12:18:48 +0200 Subject: [PATCH] Created a file called README_GIT, which has a short tutorial on git. --- gtkD/README_GIT | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 gtkD/README_GIT diff --git a/gtkD/README_GIT b/gtkD/README_GIT new file mode 100644 index 0000000..50b0039 --- /dev/null +++ b/gtkD/README_GIT @@ -0,0 +1,107 @@ +This is the public mob branch that you can push to. I created this file to test it myself. + + + +And here's a brief intro on git, which I really don't know how to use yet: + +Install git (1.5 or newer). + +First you should set your user name and info with: +[code]git config --global user.name "Your Name Comes Here" +git config --global user.email you@yourdomain.example.com[/code] + +[b]Changing the default commit message editor[/b] + +Open /home/youruser/.profile with a text editor. +Add the line +[code]GIT_EDITOR=/usr/bin/nano[/code] +When you commit stuff with git, you'll automatically have to write a commit message with a text editor. +The default is some wierd editor without any info on how to use it, so that was a big hurdle on my way +to know how to use git. Now I'm using nano which is a commandline based editor, but with a clear UI. +You propably could use any text editor like gedit or geany or whatever. But nano is good, as it starts +fast and you only need to write your commit message, and do CTRL-O to save it and CTRL-X to quit nano. + +[b]Pulling from repo.or.cz[/b] +Go to your favorite programming directory on the command line and: +[code] +mkdir gtkD +cd gtkD +git clone git://repo.or.cz/gtkD.git +[/code] +There's an awful lot of subdirs named gtkD at the moment, so excuse me for those. Not my fault entirely. + +Go to the first subdir gtkD. And write: +[code]git branch[/code] +It will give you output like: +* master +Where the star will tell you which branch you're on, and there will only be one branch called master +listed initially. If you'd have more, all their names would be listed. + +[b]Making your own local branch[/b] + +First make a new branch called mob. It will be based on the master branch as that's where you're now. (This will basically replace the files you're working on, if you've done some changes and haven't run git commit -a.) +[code]git checkout -b mob[/code] +OR +[code]git branch mob +git checkout mob[/code] + +Now you can see what branches you've got and where you're at with +[code]git branch[/code] + +Create a file with some text editor. For example yourfile.d +Add it to your branch (so that git will track it). +[code]git add yourfile.d[/code] +You'll have to commit it to your new local branch. Otherwise it will get lost when you change branches. +[code]git add yourfile.d[/code] +At anytime you can do +[code]git status[/code] +to see what you're currently doing, and haven't yet committed. (Committing means committing to your local repository, +which is basically the directory "gtkD/.git/". If you put something into the internet repositories, that is called pushing.) +So let's commit this. You'll have to commit your changes before switching branches, or otherwise they'll get lost. +[code]git commit -a[/code] +If you replaced your git editor as I told you in the beginning, you're represented with a nano screen +(or the text editor of your choise). Write some description of what you did and why. It can be long and multiline if +you want it to be, or if you've done a lot of changes. In nano you can then do CTRL-O to save it. Press ENTER to confirm +the writing on the file that it suggests. And CTRL-X to quit nano. Then it will make the changes to your current branch. +[code]git status[/code] +will tell you that there's no more changes. It will also tell you in red if you have files that are not tracked by git. +You can have such files, you don't need to add all stuff into git. Those untracked files will stay unchanged when +changing branches. + +Make changes to a file or many files. Run +[code]git status[/code] +to see some brief info on what you've done. And +[code]git diff[/code] +or +[code]git diff --cached[/code] +to see some more info. (Press Q to quit that strange viewer.) + +Commit it with +[code]git commit -a[/code] +and type in the commit message. + +You can use +[code]gitk[/code] +if you've installed gitk. It's a small app to visually see what you've done, and what branches you've got +and how they were merged. + +[b]Merging your changes to your local master branch[/b] +After you've committed all your changes switch to the master branch with +[code]git checkout master[/code] +Then merge the mob branch with your master +[code]git merge mob[/code] +I'm not going to cover problems here, so let's just assume that the merge was easy and went fine. +If you didn't make any changes to master after making changes to your mob branch then it should be fine. +If you'd have done some little feature with your mob branch then you might not need it anymore, and could +just get rid of it with (this will lose your code if it's not merged to some other branch): +[code]git branch -D mob[/code] +Or there's +[code]git branch -d mob[/code] +which will make sure you've merged it to current branch before deleting. + +Branches in git are cheap. You should branch often, but don't make it too complex for yourself. +When you've got master in good shape, and want to start on a new feature, just create a new branch, +and work on that. Once you're satisfied with it, commit, change to master (or some other), merge, +and delete the branch. You could have multiple branches where you develop many features at the same time. +Then you could make a branch just for merging them, and if that works ok, you could merge it to your master. + -- 2.11.4.GIT