]> TLD Linux GIT Repositories - TLD.git/blob - git-howto.txt
767aff9003ed4b2d1b1275794308f3b7247f135b
[TLD.git] / git-howto.txt
1 This little howto is about the Git repository used by Titanium Linux.
2 You will find here examples of the most common git commands.
3
4 Ready? Let's start (you must have RW access to TLD git repositories).
5
6 Table Of Content:
7 1. How do I prepare git to work?
8    a) Install git-core
9    b) Configure git globally
10 2. How do I commit a new .spec file or package to the repository?
11    a) Clone an empty repository (note: it will be automatically created on server
12       side.)
13    b) Set your local Email address
14    c) Put your files into the repository and add them locally
15    d) Push your changes to the server
16 3. Crap, I've checked out a repository, forgot to change the local e-mail
17    address and commited my changes. Now I can't push them to the server.
18    What can I do?
19 4. My new repository didn't show up on the web.
20 5. I've deleted some files in my cloned repo. I'm doing git pull, but they
21    do not reappear.
22 6. How can I add a description to a new repository?
23 7. SPECS: What is obsolete now that we have GIT?
24
25 ==============================================================================
26 1. How do I prepare git to work?
27
28 a) Install git-core
29
30 Just install git-core package via poldek:
31
32 poldek
33 install git-core
34
35 b) Configure git globally
36
37 To be able to work with git on TLD repository you will need to set up few
38 things in git config:
39
40 - your e-mail address which consists of your git login and tld-linux.org domain
41 - your username, which should consist of your name and surename
42
43 To do so, type:
44
45 git config --global user.email "your_git_login@tld-linux.org"
46 git config --global user.name "John Doe"
47
48 Replace "your_git_login" and "John Doe" accordingly.
49
50 Above commands will create ~/.gitconfig file with proper settings.
51
52 ==============================================================================
53 2. How do I commit a new .spec file or package to the repository?
54
55 a) Clone an empty repository (note: it will be automatically created on server
56    side.)
57
58 git clone git@git.tld-linux.org:packages/your_new_package
59
60 b) Set your local Email address
61
62 This step is optional if your git is configured globally (see point 1 of this HOWTO).
63
64 cd your_new_package
65 git config --local user.email your_git_login@tld-linux.org
66
67 This step allows you to later push your changes to the server. If you skip
68 this step, your push will fail due to a server side hook.
69
70 c) Put your files into the repository and add them locally
71
72 git add file1 file2 files*
73 git commit
74
75 d) Push your changes to the server
76
77 If you push your changes for the first time of the repositorys "life", you'll
78 need to add the origin to it.
79
80 git push origin master
81
82 After that you'll be fine by doing just:
83
84 git push
85
86 NOTE:
87
88 It is possible to shorten these commands ex. git add and git commit can be put
89 together into: git commit -a. You can commit several times into your local
90 repository before pushing all changes to server. You don't need to push each
91 time you commit, but feel free to do so if you want :-)
92
93 ==============================================================================
94 3. Crap, I've checked out a repository, forgot to change the local e-mail
95 address and commited my changes. Now I can't push them to the server.
96 What can I do?
97
98 This is very unfortunate. AFAIK you've got only 2 options.
99
100 a) Delete your commit. This means all of your changes will be lost, but you
101 can store them elsewhere for the time being, right?
102
103 To do this (after you backed up your changes) type:
104
105 git reset --hard HEAD~1
106
107 the HEAD~1 option tells git to go 1 commit back in the history. Now set your
108 local e-mail address, put back your changes and commit again. Push should now
109 work as expected.
110
111 b) The second way is to remove locally your repository and re-clone it. Then
112 put back your changes to it, commit and push.
113
114 ==============================================================================
115 4. My new repository didn't show up on the web.
116
117 Repository "packages" are checked every 15 minutes for new subrepositories by
118 a cron job. If found, they're added to the web. If for some reason cron job
119 fails, ask one of the git admins to run and/or fix this script:
120
121 ~git/scripts/packages_enable_gitweb.sh
122
123 Top level repositores have to be added manually to gitweb. Ask one of the git
124 admins to do the following:
125
126 ssh your_login@kraz.tld-linux.org
127 sudo su - git
128 cd ~/repositories/repo_name.git
129 touch gitweb-export-ok
130
131 ==============================================================================
132 5. I've deleted some files in my cloned repo. I'm doing git pull, but they
133 do not reappear.
134
135 Please do the following in your cloned repo to restore deleted files:
136
137 git checkout some.file
138
139 To restore all your deleted files do:
140
141 git ls-files -d | xargs git checkout --
142
143 ==============================================================================
144 6. How can I add a description to a new repository?
145
146 Do the following:
147
148 echo "Some description" |ssh git@git.tld-linux.org setdesc packages/some_package
149
150 Ex.
151
152 $ echo "kernel-desktop, a linux version optimised for the desktop" |ssh git@git.tld-linux.org setdesc packages/kernel-desktop
153 New description is:
154 kernel-desktop, a linux version optimised for the desktop
155 $
156
157 ==============================================================================
158 7. SPECS: What is obsolete now that we have GIT?
159
160 Now that we use GIT for our own .spec files and projects, there're some things
161 we do no longer need.
162
163 a) Remove "# $Revision:" lines on top of a .spec file
164 b) Remove the whole changelog from the bottom of a .spec file
165 c) Remove "%define date    %(echo `LC_ALL="C" date +"%a %b %d %Y"`)"
166 d) Remove feedback stuff and all PLD related links
167 e) Remove all the conditions for pld_release (%if "%{pld_release}" == "ti" ect.)
168
169 Why all that removing?
170 There're a couple of reasons why we don't want to keep these things in our 
171 specs.
172 Most of them are strictly CVS related, like the Revision stuff. We don't need
173 to artificially increase the size of our .spec files by having the whole 
174 changelog included in them. Use "git log", with all its sophisticated options,
175 to visualise changes, make statistics etc.