Merge branch 'master' of ssh://repo.or.cz/srv/git/Worg
[Worg.git] / worg-git.org
blobb562bc7bc03165e22111837ee61e52762fbfe56a
1 #+STARTUP:    align fold nodlcheck hidestars oddeven lognotestate
2 #+SEQ_TODO:   TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
3 #+TITLE:      How to use git to edit Worg files?
4 #+AUTHOR:     Worg people
5 #+TAGS:       Write(w) Update(u) Fix(f) Check(c)
6 #+EMAIL:      mdl AT imapmail DOT org
7 #+LANGUAGE:   en
8 #+PRIORITIES: A C B
9 #+CATEGORY:   worg
10 #+OPTIONS:    H:3 num:nil toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
12 [[file:index.org][{Back to Worg's index}]]
14 * What is git?
16 [[http://git.or.cz][git]] is a fast version control system that lets you collaborate on a project.
17 For details on how to use git, go and read the [[http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html][git tutorial]].  For details on
18 the public git repository, go and read the [[http://repo.or.cz/about.html][about page]] of
19 http://repo.or.cz/.
21 The homepage of the Worg project is here: http://repo.or.cz/w/Worg.git
22 You can get a read-only clone of the repository with the command:
24    : ~$ git clone http://repo.or.cz/r/Worg.git
26 Since Worg is constantly updated you may want to update your copy
27 of Worg before reading sometimes later.  To do so cd into the
28 Worg directory and upgrade your copy of Worg with the command:
30    : ~$ git pull http://repo.or.cz/r/Worg.git
32 If you want to contribute to Worg, keep reading.
34 * The first time you contribute to Worg
35   :PROPERTIES:
36   :CUSTOM_ID: contribute-to-worg
37   :END:
39 1. If you don't have a SSH-key, [[file:worg-git-ssh-key.org][create one]].
41 2. Register a [[http://repo.or.cz/reguser.cgi][new account]] on the git public repository (don't forget to
42    copy paste your public SSH key from =~/.ssh/id_rsa.pub= to the
43    registration form.)
45 3. *Drop an email to* [[mailto:mdl%20AT%20imapmail%20DOT%20org][Matt Lundin]] mentioning your username on repo.or.cz.
47 4. Install git on your system.
49 5. Clone the project somewhere in a working directory:
51    - If your user name in the shell is the same as the =Login=
52      [[http://repo.or.cz/reguser.cgi][registered at repo.or.cz]]:
54      : ~$ git clone git+ssh://repo.or.cz/srv/git/Worg.git
56    - else add the =Login= [[http://repo.or.cz/reguser.cgi][registered at repo.or.cz]] to <UserName>:
58      : ~$ git clone git+ssh://<UserName>@repo.or.cz/srv/git/Worg.git
60    If you already have your local clone of Worg obtained via http
61    protocol, you can easily tell your git to remain using http for
62    fetching and git+ssh for pushing, by adding to your ~/.gitconfig:
64      : [url "git+ssh://<UserName>@repo.or.cz/srv/git/"]
65      :   pushInsteadOf = http://repo.or.cz/r/
67    which could come handy later on for any project you clone from
68    http://repo.or.cz
70 6. Go to the newly created =Worg/= directory and edit some files.
72 7. If you created files, add them to the git index:
74    : ~$ git add *.org
76 8. Commit changes with the appropriate comment:
78    : ~$ git commit -a -m "summary comment about all changes"
80 9. Push your change to Worg:
82    - If your user name in the shell is the same as the
83      =Login= [[http://repo.or.cz/reguser.cgi][registered at repo.or.cz]]:
85      : ~$ git push
87    - else add the =Login= [[http://repo.or.cz/reguser.cgi][registered at repo.or.cz]] to <UserName>:
89      : ~$ git remote add public git+ssh://<UserName>@repo.or.cz/srv/git/Worg.git
91      Then do a:
93      : ~$ git push public
95      If you get a git error message looking like the one at the bottom
96      of this page, then this means that you've forgotten to drop a mail
97      to Matt (see step 3).
99 * The second time you contribute to Worg
101 1. Go to your =Worg/= directory.
103 2. Be sure to "pull" the last version of the repository.
105   : ~$ git pull --rebase
107 3. Make some changes.  (If you want to learn more about various git
108    workflow, read [[file:worg-git-advanced.org][this page]].)
110 4. Commit your changes on your local repository:
112    : ~$ git commit -a -m "summary comment about all changes"
114 5. Push your change on the remote repository
116    : ~$ git push
118 * Going deeper
119 ** Getting organized
121 The Worg TODO file is =worg-todo.org=.  If you are a Worg zealot, maybe you
122 want to add this file to the list of your agenda files.  For example, here
123 is my =org-agenda-files= variable:
125   : (setq org-agenda-files '("~/org/bzg.org" "~/git/Worg/worg-todo.org")
127 I have an agenda custom command for checking tasks that are assigned to me:
129   : (org-add-agenda-custom-command '("W" tags "Owner=\"Bastien\""))
131 The next time someone assigns a task for me, it will appear in my Worg
132 agenda view.
134 ** Register your changes under your name
136 Information regarding your name can be stored in your global
137 ~/.gitconfig file, or in Worg/.git/config
139 Edit it like this:
141 : [user]
142 :        name = FirstName LastName
143 :        email = you@yourdomain.example.com
145 Now your changes will be filed under your name.
147 # I'm not sure this is useful at all:
149 ** Rebase to avoid merging commits
150    It's good practice to pull the current version of the repository
151    before making your own additions. But even if you do, someone might
152    make a change while you are working. So it will often be necessary
153    to pull immediately before pushing your new commit. In this
154    situation, if you use 'git pull' directly, then a 'merge commit'
155    will be generated, looking like this:
157 #+begin_example
158 commit aaaabbbbbbbbbaaaaaaaaabbbbbbbb
159 Merge: bababa efefefef
160 Author: Some one <name@domain>
161 Date:   Wed Nov 24 00:00:01 2010 -0700
163     Merge branch 'master' of git+ssh://repo.or.cz/srv/git/Worg
164 #+end_example
166    That's not a major problem, but it's nice to keep the commit logs
167    free of this stuff. To avoid generating the merge commit, use the
168    =--rebase= option when pulling:
170   : ~$ git pull --rebase
172    Basically this means that your commit will be put to the top of the
173    stack, as if no one had made any additions while you were
174    working. More advanced git users might make their changes in a
175    personal branch, and then rebase that branch against a freshly
176    pulled master branch before merging it in to master. The end result
177    would be the same as pulling with =--rebase=.
179 ** Dealing with line endings
181 Unix, Windows and Mac all have different conventions for marking
182 the end of a line. This might lead to problems when editing the
183 same file across platforms. Github advises Linux users to
184 automatically convert all external files to LF on committing (see
185 [[http://help.github.com/dealing-with-lineendings]]) by setting:
186 : $ git config --global core.autocrlf input
187 For Worg, this is the wrong solution, since there are already
188 files with both end of line conventions in the repository.
189 Instead tell git locally not to convert files by setting:
190 : $ git config core.autocrlf false
191 Of course you have to be careful not to save Windows files as
192 Unix files or vice versa, since this would lead to large and
193 confusing diffs. This should not be a problem with Worg as
194   - one rarely edits other people's files anyway, and
195   - Emacs can deal with end of line conventions transparently.
197 ** Git usage for people who just want to send patches
199 See [[file:worg-git-advanced.org][this page]].
201 * COMMENT Anonymous editing through the "mob" user/branch
203 If you don't want to register a new account on =repo.or.gz= but still
204 want to suggest modifications on Worg, you can do this by editing the
205 "mob" branch of Worg.  For details about the =mob= user, check [[http://repo.or.cz/mob.html][this
206 webpage]] on repo.or.cz
208 This branch is usually empty, since interesting changes are quickly
209 merged into the master branch.  But it is important to make sure that
210 you pull all changes in any existing =mob= branch before trying to push
211 yours.
213 1. Clone the Worg project as the =mob= user:
215    : ~$ git clone git+ssh://mob@repo.or.cz/srv/git/Worg.git
217 2. Check out the "mob" branch to avoid conflicts between the =mob=
218    branch that you will soon create and any existing =mob= branch:
220    : ~$ git checkout origin/mob
222    You should get this warning:
224    : Note: moving to "origin/mob" which isn't a local branch
225    : If you want to create a new branch from this checkout, you may do so
226    : now or later) by using -b with the checkout command again. Example:
227    : git checkout -b <new_branch_name>
229    Don't worry.
231 3. Create a new branch named =mob= from this checkout:
233    : ~$ git checkout -b mob
235 4. Edit the files, add new files (=git-add=) and commit (=git-commit=)
236    them as usual.
238 5. Push the =mob= branch into the Worg remote directory:
240    : ~$ git push origin mob
242 You're done!
244 # FIXME:
246 # What if two people edit Worg at the same time?
247 # bzg [2009-07-15 mer]: No problem.  Just try to push and resolve
248 # conflicts if any.
250 # Can I have private sections in Worg?
251 # bzg [2009-07-15 mer]: Sure.  Just add an :AUTHOR: property in
252 # the property drawer.
254 * Example error message
256 Git error message, when you don't have push permissions to Worg:
258        : % git push
259        : Counting objects: 5, done.
260        : Delta compression using up to 2 threads.
261        : Compressing objects: 100% (3/3), done.
262        : Writing objects: 100% (3/3), 463 bytes, done.
263        : Total 3 (delta 2), reused 0 (delta 0)
264        : error: unable to create temporary sha1 filename ./objects/64: File exists
265        :
266        : fatal: failed to write object
267        : error: unpack failed: unpacker exited with error code
268        : To git+ssh://myUserName@repo.or.cz/srv/git/Worg.git
269        :  ! [remote rejected] master -> master (n/a (unpacker error))
270        : error: failed to push some refs to
271        :   'git+ssh://myUserName@repo.or.cz/srv/git/Worg.git'