author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Tue, 01 Mar 2011 16:41:25 +0200 | |
changeset 832 | d3b96f56c613 |
parent 828 | e75285735442 |
child 833 | 2fc97313ce78 |
permissions | -rw-r--r-- |
735 | 1 |
-*- mode: outline; coding: utf-8; fill-column: 80 -*- |
61 | 2 |
|
3 |
* Setup git. |
|
4 |
||
5 |
** Debian. |
|
6 |
||
7 |
For Etch Degian release use git-core package from backports, |
|
8 |
old 1.4 version of git very dumb compared to new version 1.5. |
|
9 |
||
10 |
$ sudo apt-get install git-core |
|
11 |
||
12 |
After install setup some options: |
|
13 |
||
14 |
$ git config --global user.name "Oleksandr Gavenko" |
|
15 |
$ git config --global user.mail "gavenkoa@gmail.com" |
|
16 |
$ cat ~/.gitconfig |
|
17 |
[user] |
|
18 |
name = Oleksandr Gavenko |
|
19 |
mail = gavenkoa@gmail.com |
|
20 |
||
230 | 21 |
** Windows. |
22 |
||
23 |
No official support for Windows OS. |
|
24 |
||
25 |
*** Cygwin. |
|
26 |
||
832 | 27 |
$ setup.exe -p git |
28 |
||
230 | 29 |
*** MSys. |
30 |
||
31 |
Native port. |
|
32 |
||
231
3b3680e6d481
How config git on windows.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
33 |
$ cat gitconfig |
3b3680e6d481
How config git on windows.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
34 |
[core] |
3b3680e6d481
How config git on windows.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
35 |
autocrlf = false |
3b3680e6d481
How config git on windows.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
36 |
symlinks = false |
3b3680e6d481
How config git on windows.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
230
diff
changeset
|
37 |
|
230 | 38 |
http://code.google.com/p/msysgit |
39 |
||
828 | 40 |
* git over proxy. |
41 |
||
42 |
Only http:// protocol support proxy (not git://). |
|
43 |
||
44 |
$ export http_proxy="http://username:password@proxy:port/" |
|
45 |
$ git clone http://github.com/$user/$proj.git $proj |
|
46 |
||
61 | 47 |
* Start your project. |
48 |
||
49 |
Setup proj space on fs. |
|
50 |
||
51 |
$ mkdir proj |
|
52 |
$ cd proj |
|
53 |
$ git init |
|
54 |
Initialized empty Git repository in /home/user/tmp/proj/.git/ |
|
55 |
$ ls -a |
|
56 |
. .. .git |
|
57 |
||
58 |
Add file, make changes, commit all. |
|
59 |
||
60 |
$ emacs Makefile |
|
61 |
... C-x C-c |
|
62 |
$ emacs app.c |
|
63 |
... C-x C-c |
|
64 |
$ git add Makefile app.c |
|
65 |
$ git status |
|
66 |
# On branch master |
|
67 |
# |
|
68 |
# Initial commit |
|
69 |
# |
|
70 |
# Changes to be committed: |
|
71 |
# (use "git rm --cached <file>..." to unstage) |
|
72 |
# |
|
73 |
# new file: Makefile |
|
74 |
# new file: app.c |
|
75 |
# |
|
76 |
||
77 |
or just |
|
78 |
||
79 |
$ git add . |
|
80 |
||
81 |
Commit newlly added file: |
|
82 |
||
83 |
$ git commit |
|
84 |
... Write message log ... |
|
85 |
Created initial commit 2169263: My first commit massage. |
|
86 |
1 files changed, 4 insertions(+), 0 deletions(-) |
|
87 |
create mode 100644 app.c |
|
88 |
||
89 |
* Undo tracking added file. |
|
90 |
||
91 |
You do |
|
92 |
||
93 |
$ git add badfile |
|
94 |
$ git status |
|
95 |
# On branch master |
|
96 |
# Changes to be committed: |
|
97 |
# (use "git reset HEAD <file>..." to unstage) |
|
98 |
# |
|
99 |
# new file: badfile |
|
100 |
# |
|
101 |
||
102 |
To stop tracking badfile do |
|
103 |
||
104 |
$ git rm --cached badfile |
|
105 |
$ git status |
|
106 |
# On branch master |
|
107 |
# Untracked files: |
|
108 |
# (use "git add <file>..." to include in what will be committed) |
|
109 |
# |
|
110 |
# file |
|
111 |
nothing added to commit but untracked files present (use "git add" to track) |
|
112 |
||
113 |
or |
|
114 |
||
115 |
$ git reset badfile |
|
116 |
||
117 |
* Doing changes. |
|
118 |
||
119 |
$ printf "clean:\n<TAB>rm $(wildcard *.o)" >>Makefile |
|
120 |
$ git diff |
|
121 |
diff --git a/Makefile b/Makefile |
|
122 |
index e84f7e9..cd2438a 100644 |
|
123 |
--- a/Makefile |
|
124 |
+++ b/Makefile |
|
125 |
@@ -1,2 +1,5 @@ |
|
126 |
all: |
|
127 |
@echo XXX |
|
128 |
exit 1 |
|
129 |
+ |
|
130 |
+clean: |
|
131 |
+ rm -f *.o |
|
132 |
\ No newline at end of file |
|
133 |
$ git add Makefile |
|
134 |
$ git commit -m "Added clean target." |
|
135 |
Created commit 11272b9: Added clean target. |
|
136 |
1 files changed, 1 insertions(+), 0 deletions(-) |
|
137 |
create mode 100644 file |
|
138 |
||
139 |
or just |
|
140 |
||
141 |
$ git commit -a -m "Added clean target." |
|
142 |
||
143 |
* Using git to work with SVN offline. |
|
144 |
||
62 | 145 |
Prepare SVN and git utilities: |
146 |
||
61 | 147 |
$ sudo apt-get svn git-core git-svn |
62 | 148 |
|
149 |
Making SVN repo |
|
150 |
||
151 |
$ cd $HOME/tmp |
|
152 |
$ svnadmin create svn-repo |
|
153 |
$ svn co file://$HOME/tmp/svn-repo svn-devel |
|
154 |
$ cd svn-devel |
|
155 |
$ mkdir tags trunk branches |
|
156 |
$ svn add * |
|
157 |
A branches |
|
158 |
A tags |
|
159 |
A trunk |
|
160 |
$ cd trunk/ |
|
161 |
$ printf "all:\n echo XXX\n" >Makefile |
|
162 |
$ printf "int main() {return 0;}" >main.c |
|
163 |
$ svn add * |
|
164 |
$ cd .. |
|
165 |
$ svn st |
|
166 |
A trunk |
|
167 |
A trunk/main.c |
|
168 |
A trunk/Makefile |
|
169 |
A branches |
|
170 |
A tags |
|
171 |
$ svn ci -m init |
|
172 |
Adding branches |
|
173 |
Adding tags |
|
174 |
Adding trunk |
|
175 |
Adding trunk/Makefile |
|
176 |
Adding trunk/main.c |
|
177 |
Transmitting file data .. |
|
178 |
$ svn cp -m v0.0 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/tags/v0.0 |
|
179 |
$ svn cp -m v0.1 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/branches/v0.1 |
|
180 |
||
181 |
Moving SVN changset to git repo |
|
182 |
||
183 |
$ cd $HOME/tmp |
|
63 | 184 |
$ git svn init file://$HOME/tmp/svn git-repo |
62 | 185 |
$ ls -a |
186 |
. .. .git |
|
187 |
$ git svn fetch |
|
188 |
A trunk/main.c |
|
189 |
A trunk/Makefile |
|
190 |
W: +empty_dir: branches |
|
191 |
W: +empty_dir: tags |
|
192 |
r1 = 52ccd9882979dd53ec198dbac108783ec660410f (git-svn) |
|
193 |
A tags/v0.0/main.c |
|
194 |
A tags/v0.0/Makefile |
|
195 |
r2 = 8ec8a772bb6f37ace56b3649066dc84e481ed427 (git-svn) |
|
196 |
M trunk/Makefile |
|
197 |
r3 = 2c169ff409ed504dd6a092b1e302beb3fd94871e (git-svn) |
|
198 |
A branches/v0.1/main.c |
|
199 |
A branches/v0.1/Makefile |
|
200 |
r4 = e68d76f4ba6beea4b9059c1884c1f38ce10831a7 (git-svn) |
|
201 |
M trunk/Makefile |
|
202 |
r5 = cdde63974454b13ac53f2eeb201aa76c49fd875c (git-svn) |
|
203 |
Checked out HEAD: |
|
204 |
file:///home/sasha/tmp/svn r5 |
|
205 |
||
63 | 206 |
or (in old git version): |
207 |
||
208 |
$ git svn clone file://$HOME/tmp/svn git-repo |
|
209 |
||
62 | 210 |
Making changes in svn: |
211 |
||
212 |
$ cd $HOME/tmp/svn-devel/trunk |
|
213 |
$ echo ".PHONY: clean" >>Makefile |
|
214 |
$ svn ci -m "Added clean to phony." |
|
215 |
Sending trunk/Makefile |
|
216 |
Transmitting file data . |
|
217 |
Committed revision 6. |
|
218 |
||
219 |
Making committed in git: |
|
220 |
||
221 |
$ cd $HOME/tmp/git-repo/trunk |
|
222 |
$ echo ".PHONY: all" >>Makefile |
|
223 |
$ echo "int foo(int x) {return x+x;}" >>main.c |
|
224 |
$ git status |
|
225 |
# On branch master |
|
226 |
# Changed but not updated: |
|
227 |
# (use "git add <file>..." to update what will be committed) |
|
228 |
# |
|
229 |
# modified: Makefile |
|
230 |
# modified: main.c |
|
231 |
# |
|
232 |
no changes added to commit (use "git add" and/or "git commit -a") |
|
233 |
$ git commit -a -m "Bug fixed." |
|
234 |
Created commit 222d399: Bug fixed. |
|
235 |
2 files changed, 2 insertions(+), 0 deletions(-) |
|
236 |
||
237 |
Getting changes from SVN to git: |
|
238 |
||
239 |
$ git svn rebase |
|
240 |
M trunk/Makefile |
|
241 |
r6 = 8165e9bfb38e9df09a7313d19606ec227629b670 (git-svn) |
|
242 |
First, rewinding head to replay your work on top of it... |
|
243 |
Applying Bug fixed. |
|
244 |
error: patch failed: trunk/Makefile:6 |
|
245 |
error: trunk/Makefile: patch does not apply |
|
246 |
Using index info to reconstruct a base tree... |
|
247 |
Falling back to patching base and 3-way merge... |
|
248 |
Auto-merged trunk/Makefile |
|
249 |
CONFLICT (content): Merge conflict in trunk/Makefile |
|
250 |
Failed to merge in the changes. |
|
251 |
Patch failed at 0001. |
|
252 |
||
253 |
When you have resolved this problem run "git rebase --continue". |
|
254 |
If you would prefer to skip this patch, instead run "git rebase --skip". |
|
255 |
To restore the original branch and stop rebasing run "git rebase --abort". |
|
256 |
||
257 |
rebase refs/remotes/git-svn: command returned error: 1 |
|
258 |
$ git add Makefile |
|
259 |
$ git rebase --continue |
|
260 |
Applying Bug fixed. |
|
261 |
||
262 |
and return all from git to SVN: |
|
263 |
||
264 |
$ git svn dcommit |
|
265 |
Committing to file:///home/sasha/tmp/svn ... |
|
266 |
M trunk/Makefile |
|
267 |
M trunk/main.c |
|
268 |
Committed r7 |
|
269 |
M trunk/main.c |
|
270 |
M trunk/Makefile |
|
271 |
r7 = 68e782c8d06635f2db4dd69b9ca8599f99da22e2 (git-svn) |
|
272 |
No changes between current HEAD and refs/remotes/git-svn |
|
273 |
Resetting to the latest refs/remotes/git-svn |
|
274 |
||
275 |
See what going to SVN repo: |
|
276 |
||
277 |
$ cd $HOME/tmp/svn-devel/trunk |
|
278 |
$ svn diff -r BASE:HEAD |
|
279 |
Index: Makefile |
|
280 |
=================================================================== |
|
281 |
--- Makefile (working copy) |
|
282 |
+++ Makefile (revision 7) |
|
283 |
@@ -6,4 +6,4 @@ |
|
284 |
.o: .c |
|
285 |
$(CC) $(CFLAGS) -c -o $@ $< |
|
286 |
||
287 |
-.PHONY: clean |
|
288 |
+.PHONY: all clean |
|
289 |
Index: main.c |
|
290 |
=================================================================== |
|
291 |
--- main.c (working copy) |
|
292 |
+++ main.c (revision 7) |
|
293 |
@@ -2,3 +2,4 @@ |
|
294 |
{ |
|
295 |
return 0; |
|
296 |
} |
|
297 |
+int foo(int x) {return x+x;} |
|
298 |
$ svn up |
|
299 |
U Makefile |
|
300 |
U main.c |
|
301 |
Updated to revision 7. |
|
302 |
||
64 | 303 |
* gitk |
62 | 304 |
|
64 | 305 |
gitk - The git repository browser |
306 |
||
307 |
Installing: |
|
308 |
||
309 |
$ sudo apt-get instal gitk |
|
310 |
||
311 |
Using: |
|
312 |
||
313 |
$ cd /path/to/git-repo |
|
314 |
$ gitk |
|
315 |
||
316 |
See |
|
317 |
||
318 |
gitk(1) |