author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Tue, 01 Mar 2011 17:16:20 +0200 | |
changeset 836 | 64ecb45d68fa |
parent 835 | d0bddeaf586b |
child 899 | 7b4265c8d324 |
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 |
||
836
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
47 |
You can store proxy settings under repository local config file: |
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
48 |
|
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
49 |
$ git config http.proxy http://$user:$passwd@$ip:$port |
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
50 |
|
61 | 51 |
* Start your project. |
52 |
||
53 |
Setup proj space on fs. |
|
54 |
||
55 |
$ mkdir proj |
|
56 |
$ cd proj |
|
57 |
$ git init |
|
58 |
Initialized empty Git repository in /home/user/tmp/proj/.git/ |
|
59 |
$ ls -a |
|
60 |
. .. .git |
|
61 |
||
62 |
Add file, make changes, commit all. |
|
63 |
||
64 |
$ emacs Makefile |
|
65 |
... C-x C-c |
|
66 |
$ emacs app.c |
|
67 |
... C-x C-c |
|
68 |
$ git add Makefile app.c |
|
69 |
$ git status |
|
70 |
# On branch master |
|
71 |
# |
|
72 |
# Initial commit |
|
73 |
# |
|
74 |
# Changes to be committed: |
|
75 |
# (use "git rm --cached <file>..." to unstage) |
|
76 |
# |
|
77 |
# new file: Makefile |
|
78 |
# new file: app.c |
|
79 |
# |
|
80 |
||
81 |
or just |
|
82 |
||
83 |
$ git add . |
|
84 |
||
85 |
Commit newlly added file: |
|
86 |
||
87 |
$ git commit |
|
88 |
... Write message log ... |
|
89 |
Created initial commit 2169263: My first commit massage. |
|
90 |
1 files changed, 4 insertions(+), 0 deletions(-) |
|
91 |
create mode 100644 app.c |
|
92 |
||
93 |
* Undo tracking added file. |
|
94 |
||
95 |
You do |
|
96 |
||
97 |
$ git add badfile |
|
98 |
$ git status |
|
99 |
# On branch master |
|
100 |
# Changes to be committed: |
|
101 |
# (use "git reset HEAD <file>..." to unstage) |
|
102 |
# |
|
103 |
# new file: badfile |
|
104 |
# |
|
105 |
||
106 |
To stop tracking badfile do |
|
107 |
||
108 |
$ git rm --cached badfile |
|
109 |
$ git status |
|
110 |
# On branch master |
|
111 |
# Untracked files: |
|
112 |
# (use "git add <file>..." to include in what will be committed) |
|
113 |
# |
|
114 |
# file |
|
115 |
nothing added to commit but untracked files present (use "git add" to track) |
|
116 |
||
117 |
or |
|
118 |
||
119 |
$ git reset badfile |
|
120 |
||
121 |
* Doing changes. |
|
122 |
||
835 | 123 |
$ printf "clean:\n<TAB>rm $(wildcard *.o)\n" >>Makefile |
61 | 124 |
$ git diff |
125 |
diff --git a/Makefile b/Makefile |
|
126 |
index e84f7e9..cd2438a 100644 |
|
127 |
--- a/Makefile |
|
128 |
+++ b/Makefile |
|
129 |
@@ -1,2 +1,5 @@ |
|
130 |
all: |
|
131 |
@echo XXX |
|
132 |
exit 1 |
|
133 |
+ |
|
134 |
+clean: |
|
135 |
+ rm -f *.o |
|
136 |
$ git add Makefile |
|
137 |
$ git commit -m "Added clean target." |
|
138 |
Created commit 11272b9: Added clean target. |
|
139 |
1 files changed, 1 insertions(+), 0 deletions(-) |
|
140 |
create mode 100644 file |
|
141 |
||
142 |
or just |
|
143 |
||
144 |
$ git commit -a -m "Added clean target." |
|
145 |
||
833
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
146 |
* git analog of 'hg incoming'. |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
147 |
|
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
148 |
git does not directly support such feature. You can emulate it by: |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
149 |
|
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
150 |
$ git fetch |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
151 |
$ git log master..origin/master # or just '..origin/master' |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
152 |
|
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
153 |
By previous commands you grab changes from remote server! You can apply them: |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
154 |
|
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
155 |
TODO |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
156 |
$ git merge |
2fc97313ce78
git analog of 'hg incoming'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
832
diff
changeset
|
157 |
|
836
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
158 |
* git analog of 'hg outgoing'. |
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
159 |
|
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
160 |
git does not directly support such feature. You can emulate it by: |
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
161 |
|
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
162 |
$ git fetch |
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
163 |
$ git log origin/master..master # or just 'origin/master..' |
64ecb45d68fa
git analog of 'hg outgoing'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
835
diff
changeset
|
164 |
|
834
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
165 |
* Debug git network operation. |
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
166 |
|
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
167 |
Git uses libcurl for network operation. |
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
168 |
|
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
169 |
$ export GIT_CURL_VERBOSE=1 |
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
170 |
$ git ... |
5bed6172a7c4
Debug git network operation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
833
diff
changeset
|
171 |
|
61 | 172 |
* Using git to work with SVN offline. |
173 |
||
62 | 174 |
Prepare SVN and git utilities: |
175 |
||
61 | 176 |
$ sudo apt-get svn git-core git-svn |
62 | 177 |
|
178 |
Making SVN repo |
|
179 |
||
180 |
$ cd $HOME/tmp |
|
181 |
$ svnadmin create svn-repo |
|
182 |
$ svn co file://$HOME/tmp/svn-repo svn-devel |
|
183 |
$ cd svn-devel |
|
184 |
$ mkdir tags trunk branches |
|
185 |
$ svn add * |
|
186 |
A branches |
|
187 |
A tags |
|
188 |
A trunk |
|
189 |
$ cd trunk/ |
|
190 |
$ printf "all:\n echo XXX\n" >Makefile |
|
191 |
$ printf "int main() {return 0;}" >main.c |
|
192 |
$ svn add * |
|
193 |
$ cd .. |
|
194 |
$ svn st |
|
195 |
A trunk |
|
196 |
A trunk/main.c |
|
197 |
A trunk/Makefile |
|
198 |
A branches |
|
199 |
A tags |
|
200 |
$ svn ci -m init |
|
201 |
Adding branches |
|
202 |
Adding tags |
|
203 |
Adding trunk |
|
204 |
Adding trunk/Makefile |
|
205 |
Adding trunk/main.c |
|
206 |
Transmitting file data .. |
|
207 |
$ svn cp -m v0.0 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/tags/v0.0 |
|
208 |
$ svn cp -m v0.1 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/branches/v0.1 |
|
209 |
||
210 |
Moving SVN changset to git repo |
|
211 |
||
212 |
$ cd $HOME/tmp |
|
63 | 213 |
$ git svn init file://$HOME/tmp/svn git-repo |
62 | 214 |
$ ls -a |
215 |
. .. .git |
|
216 |
$ git svn fetch |
|
217 |
A trunk/main.c |
|
218 |
A trunk/Makefile |
|
219 |
W: +empty_dir: branches |
|
220 |
W: +empty_dir: tags |
|
221 |
r1 = 52ccd9882979dd53ec198dbac108783ec660410f (git-svn) |
|
222 |
A tags/v0.0/main.c |
|
223 |
A tags/v0.0/Makefile |
|
224 |
r2 = 8ec8a772bb6f37ace56b3649066dc84e481ed427 (git-svn) |
|
225 |
M trunk/Makefile |
|
226 |
r3 = 2c169ff409ed504dd6a092b1e302beb3fd94871e (git-svn) |
|
227 |
A branches/v0.1/main.c |
|
228 |
A branches/v0.1/Makefile |
|
229 |
r4 = e68d76f4ba6beea4b9059c1884c1f38ce10831a7 (git-svn) |
|
230 |
M trunk/Makefile |
|
231 |
r5 = cdde63974454b13ac53f2eeb201aa76c49fd875c (git-svn) |
|
232 |
Checked out HEAD: |
|
233 |
file:///home/sasha/tmp/svn r5 |
|
234 |
||
63 | 235 |
or (in old git version): |
236 |
||
237 |
$ git svn clone file://$HOME/tmp/svn git-repo |
|
238 |
||
62 | 239 |
Making changes in svn: |
240 |
||
241 |
$ cd $HOME/tmp/svn-devel/trunk |
|
242 |
$ echo ".PHONY: clean" >>Makefile |
|
243 |
$ svn ci -m "Added clean to phony." |
|
244 |
Sending trunk/Makefile |
|
245 |
Transmitting file data . |
|
246 |
Committed revision 6. |
|
247 |
||
248 |
Making committed in git: |
|
249 |
||
250 |
$ cd $HOME/tmp/git-repo/trunk |
|
251 |
$ echo ".PHONY: all" >>Makefile |
|
252 |
$ echo "int foo(int x) {return x+x;}" >>main.c |
|
253 |
$ git status |
|
254 |
# On branch master |
|
255 |
# Changed but not updated: |
|
256 |
# (use "git add <file>..." to update what will be committed) |
|
257 |
# |
|
258 |
# modified: Makefile |
|
259 |
# modified: main.c |
|
260 |
# |
|
261 |
no changes added to commit (use "git add" and/or "git commit -a") |
|
262 |
$ git commit -a -m "Bug fixed." |
|
263 |
Created commit 222d399: Bug fixed. |
|
264 |
2 files changed, 2 insertions(+), 0 deletions(-) |
|
265 |
||
266 |
Getting changes from SVN to git: |
|
267 |
||
268 |
$ git svn rebase |
|
269 |
M trunk/Makefile |
|
270 |
r6 = 8165e9bfb38e9df09a7313d19606ec227629b670 (git-svn) |
|
271 |
First, rewinding head to replay your work on top of it... |
|
272 |
Applying Bug fixed. |
|
273 |
error: patch failed: trunk/Makefile:6 |
|
274 |
error: trunk/Makefile: patch does not apply |
|
275 |
Using index info to reconstruct a base tree... |
|
276 |
Falling back to patching base and 3-way merge... |
|
277 |
Auto-merged trunk/Makefile |
|
278 |
CONFLICT (content): Merge conflict in trunk/Makefile |
|
279 |
Failed to merge in the changes. |
|
280 |
Patch failed at 0001. |
|
281 |
||
282 |
When you have resolved this problem run "git rebase --continue". |
|
283 |
If you would prefer to skip this patch, instead run "git rebase --skip". |
|
284 |
To restore the original branch and stop rebasing run "git rebase --abort". |
|
285 |
||
286 |
rebase refs/remotes/git-svn: command returned error: 1 |
|
287 |
$ git add Makefile |
|
288 |
$ git rebase --continue |
|
289 |
Applying Bug fixed. |
|
290 |
||
291 |
and return all from git to SVN: |
|
292 |
||
293 |
$ git svn dcommit |
|
294 |
Committing to file:///home/sasha/tmp/svn ... |
|
295 |
M trunk/Makefile |
|
296 |
M trunk/main.c |
|
297 |
Committed r7 |
|
298 |
M trunk/main.c |
|
299 |
M trunk/Makefile |
|
300 |
r7 = 68e782c8d06635f2db4dd69b9ca8599f99da22e2 (git-svn) |
|
301 |
No changes between current HEAD and refs/remotes/git-svn |
|
302 |
Resetting to the latest refs/remotes/git-svn |
|
303 |
||
304 |
See what going to SVN repo: |
|
305 |
||
306 |
$ cd $HOME/tmp/svn-devel/trunk |
|
307 |
$ svn diff -r BASE:HEAD |
|
308 |
Index: Makefile |
|
309 |
=================================================================== |
|
310 |
--- Makefile (working copy) |
|
311 |
+++ Makefile (revision 7) |
|
312 |
@@ -6,4 +6,4 @@ |
|
313 |
.o: .c |
|
314 |
$(CC) $(CFLAGS) -c -o $@ $< |
|
315 |
||
316 |
-.PHONY: clean |
|
317 |
+.PHONY: all clean |
|
318 |
Index: main.c |
|
319 |
=================================================================== |
|
320 |
--- main.c (working copy) |
|
321 |
+++ main.c (revision 7) |
|
322 |
@@ -2,3 +2,4 @@ |
|
323 |
{ |
|
324 |
return 0; |
|
325 |
} |
|
326 |
+int foo(int x) {return x+x;} |
|
327 |
$ svn up |
|
328 |
U Makefile |
|
329 |
U main.c |
|
330 |
Updated to revision 7. |
|
331 |
||
64 | 332 |
* gitk |
62 | 333 |
|
64 | 334 |
gitk - The git repository browser |
335 |
||
336 |
Installing: |
|
337 |
||
338 |
$ sudo apt-get instal gitk |
|
339 |
||
340 |
Using: |
|
341 |
||
342 |
$ cd /path/to/git-repo |
|
343 |
$ gitk |
|
344 |
||
345 |
See |
|
346 |
||
347 |
gitk(1) |