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