1
- # 代码托管网站:
1
+ # VCS(Version Control System)学习之路
2
+
3
+ ## 代码托管网站
2
4
3
5
* https://github.com/ (Git)
4
6
* http://www.gitlab.cc/ (Git)
19
21
* <del >http://www.svnhost.cn/ </del > (SVN)
20
22
* <del >http://www.chinasvn.com </del > (SVN)
21
23
22
-
23
- # SVN
24
-
25
- ## 项目地址:
24
+ ## SVN
26
25
27
26
* 原项目地址,现在仍保留:http://subversion.tigris.org/
28
27
* 现在:http://subversion.apache.org/
36
35
* SVNKit:http://www.svnkit.com/index.html
37
36
* VISUALSVN SERVER // Features // Windows Authentication for Subversion: https://www.visualsvn.com/server/features/windows-auth/
38
37
39
-
40
- ## 教程地址:
41
-
42
38
* Subversion 与版本控制:http://svnbook.red-bean.com/
43
39
* TortoiseSVN:http://tortoisesvn.net/docs/release/TortoiseSVN_en/index.html
44
40
* TortoiseSVN命令行:http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-automation.html
54
50
* SVN版本库无损迁移与自动备份(二):http://www.cnblogs.com/springside-example/archive/2011/11/30/2530174.html
55
51
* SVN+Apache域用户认证配置方法_Windows(转,重新排版,部分内容更新优化): http://www.cnblogs.com/jiangxinnju/p/5906377.html
56
52
* TortoiseSVN,TortoiseGit修改差异查看器为BeyondCompare: http://blog.csdn.net/sanfye/article/details/48028879
53
+ * SVN的钩子--限制强制写日志(log): < http://duchengjiu.iteye.com/blog/1739694 >
54
+ * svn ignore 的用法(忽略文件及目录): < http://blog.csdn.net/yhl27/article/details/24318001 >
55
+ * SVN版本冲突,COMMIT时出现.MINE等文件: < https://www.cnblogs.com/xiezhengcai/archive/2013/06/06/3120931.html >
57
56
58
-
59
- ## 简单教程(详细说明参考前面的教程地址,此处仅为了速查速用)
57
+ ### 简单教程(详细说明参考前面的教程地址,此处仅为了速查速用)
60
58
61
59
以Win32SVN为例,在前面所列的地址中下载Win32SVN客户端并进行安装。安装好后,bin目录下就是相应程序了。通过添加环境变量的方式,把bin目录添加到path。启动cmd,敲入 svn help 以确认是否安装成功。现在可以找到你的代码,做checkout了。在commit代码的过程中,经常会出现的一个问题是:
62
60
78
76
79
77
知道了子命令,但是不知道子命令的用法,还可以查询:
80
78
81
- svn help ci
79
+ svn help ci
82
80
83
81
导入项目
84
82
132
130
svn log directory
133
131
svn log file
134
132
135
-
136
- ## svn ignore的用法
137
-
138
- 若想创建了一个文件夹,并且把它加入版本控制,但忽略文件夹中的所有文件的内容:
139
-
140
- svn mkdir spool
141
- svn propset svn:ignore '*' spool
142
- svn ci -m 'Adding "spool" and ignoring its contents.'
143
-
144
- 若想创建一个文件夹,但不加入版本控制,即忽略这个文件夹:
145
-
146
- mkdir spool
147
- svn propset svn:ignore 'spool' .
148
- svn ci -m 'Ignoring a directory called "spool".'
149
-
150
- 若已经创建了文件夹,并加入了版本控制,现在想忽略这个文件夹,但要保持文件夹的内容:
151
-
152
- svn export spool spool-tmp
153
- svn rm spool
154
- svn ci -m 'Removing inadvertently added directory "spool".'
155
- mv spool-tmp spool
156
- svn propset svn:ignore 'spool' .
157
- svn ci -m 'Ignoring a directory called "spool".'
158
-
159
- 如果想在SVN提交时,忽略某个文件,也就是某个文件不提交,可以使用
160
-
161
- svn propedit svn:ignore 目录名称
162
-
163
- 注意,在使用这个SVN的属性编辑前,你得确保后面的“目录名称”是SVN版本控制的目录。如果要忽略此目录下的文件,可以如下操作。比如,想忽略/product目录下的test.php文件。前提是/product目录必须在svn版本控制下,而test.php文件不在svn版本控制。svn st先看一下状态,会显示如下:
164
-
165
- ? /product/test.php
166
-
167
- 我们需要将test.php文件加入忽略列表。此时先设置SVN默认的编辑器
168
-
169
- export SVN_EDITOR=vim
170
-
171
- 然后:
172
-
173
- svn propedit svn:ignore /product
174
-
175
- 此时会出现一个VIM的编辑窗口,表示需要将某个文件加入到忽略列表里。我们在编辑窗口中,写入test.php。然后保存,并退出VIM编辑器。这时候会有一个提示:
176
-
177
- 属性 “svn:ignore” 于 “product” 被设为新值。
178
-
179
- 表示文件test.php的svn: ignore 属性设置成功。然后使用svn st查看,会显示:
180
-
181
- M product
182
-
183
- 我们需要提交,然后这个svn: ignore 属性才会起作用
184
-
185
- svn ci -m '忽略test.php文件'
186
-
187
- 这时候,无论你如何修改test.php文件,再使用svn st时,也不会出现修改提示符合M了。
188
-
189
- ## SVN更新失败,提示locked
133
+ ### SVN更新失败,提示locked
190
134
191
135
产生这种情况大多是因为上次svn命令执行失败且被锁定了,需要删除文件夹中的lock文件,即可解锁。这里介绍3种方法:
192
136
193
137
* 直接进行cleanup;对较小的文件比较管用,文件稍大些等待时间很长或不起作用;
194
138
* 选择文件,右键执行release lock;等待时间较长;
195
139
* 手动删除锁定文件:在命令提示符下cd 到svn项目出现问题的文件所在目录下,执行命令del lock /q/s。等待删除lock文件成功,重新更新SVN。
196
140
141
+ ## GIT
197
142
198
- ## SVN版本冲突,commit时出现.mine等文件
199
-
200
- 以commit后自动生成R.java.mine,R.java.r3368,R.java.r3439为例。因为发生冲突了,别人和你都从3368这个版本对r.java这个文件进行了修改,别人修改后先提交了形成3439版本,然后你做了提交操作,这时为了避免你覆盖别人的修改工作,SVN提示你发生了冲突,并自动形成R.java.mine、R.java.r3368、R.java.r3439这三个文件。其中:
201
-
202
- * R.java.mine 你自己修改后准备提交的那个版本;
203
- * R.java.r3368 你们的初始版本;
204
- * R.java.r3439 别人在你之前提交的那个版本;
205
- * R.java 自动合并了你的版本和别人提交的版本形成的(其中用<<<<<、======、>>>>>等符号标记出了自动合并的部分)。
206
-
207
- 自动生成这些文件的目的是便于你手动合并你们两个人的修改。这时建议你查看一下这个文件的历史记录,看看3439这个版本是谁提交的,问问他修改了什么地方,然后你手动将你们两个人的修改合并到同一个文件r.java中,然后使用SVN标记“冲突已解决”,标记后多余的文件会被自动删除,然后你就可以正常提交了。
208
-
209
-
210
- ## SVN的钩子--限制强制写日志
211
-
212
- SVN本身并不提供这种强制写log的功能,而是通过一系列的钩子程序(我们称为hook脚本),在提交之前(pre-commit),提交过程中(start-commit),提交之后(post-commit),调用预定的钩子程序来完成一些附加的功能。本次我们要实现的是在提交到版本库之前检查用户是否已经写了注释,当然要使用pre-commit这个钩子程序。我们打开SVN的repository下的hook目录,可以发现有好几个文件,其中一个是“pre-commit.tmpl”。这个文件是一个模板文件,它告诉了我们如何实现提交前控制。打开该模板文件,我们看到如下一段说明:
213
-
214
- ``` shell
215
- # The pre-commit hook is invoked before a Subversion txn is
216
- # committed. Subversion runs this hook by invoking a program
217
- # (script, executable, binary, etc.) named 'pre-commit' (for which
218
- # this file is a template), with the following ordered arguments:
219
- #
220
- # [1] REPOS-PATH (the path to this repository)
221
- # [2] TXN-NAME (the name of the txn about to be committed)
222
- #
223
- # The default working directory for the invocation is undefined, so
224
- # the program should set one explicitly if it cares.
225
- #
226
- # If the hook program exits with success, the txn is committed; but
227
- # if it exits with failure (non-zero), the txn is aborted, no commit
228
- # takes place, and STDERR is returned to the client. The hook
229
- # program can use the 'svnlook' utility to help it examine the txn.
230
- ```
231
-
232
- 我们看到在一个提交事务执行之前,该hook脚本会被调用。然后向该脚本传递两个参数:REPOS-PATH和TXN-NAME,一个是用户要提交的URL,一个是本次事务的一个事务号。如果提交成功则返回0,否则返回其它非0结果。那么我们的钩子程序就是要在事务提交之前,拦截这些请求,然后通过svnlook命令来检查是否已经写了log。示例代码:
233
-
234
- ``` shell
235
- REPOS=" $1 "
236
- TXN=" $2 "
237
- # Make sure that the log message contains some text.
238
- SVNLOOK=/usr/bin/svnlook
239
- LOGMSG=$( $SVNLOOK log -t " $TXN " " $REPOS " | \
240
- grep " [a-zA-Z0-9]" | wc -c)
241
- if [ " $LOGMSG " -lt 48 ]; then
242
- # -eq 等于号 -gt 大于号 -lt小于号 ,显示输入的长短为10(如果数字或者字母表示最少要写9个,如果汉字是一个根据自己的需求可以任意修改
243
- echo -e " \n至少输入4个汉字" >&2
244
- exit 1
245
- fi
246
- exit 0
247
- ```
248
-
249
-
250
- # GIT
143
+ 安装了git后会附带很多linux下常用的工具,比如ssh,scp,curl,split,cat等,很方便。
251
144
252
- ## 项目地址:
145
+ * GIT:< http://git-scm.com/ >
146
+ * Reference:< http://git-scm.com/docs >
147
+ * Documentation:< http://git-scm.com/doc >
148
+ * Pro Git book: < https://git-scm.com/book/en >
253
149
254
- * GIT: http://git-scm.com/
255
- * git for windows: https://git-for-windows. github.io/
150
+ * git for windows: < http://gitforwindows.org/ >
151
+ * posh- git: < https://github.com/dahlbyk/posh-git >
256
152
* SourceTree:https://www.sourcetreeapp.com/
257
153
* tortoisegit:https://code.google.com/p/tortoisegit/
258
154
* gitlab:https://about.gitlab.com/
@@ -270,12 +166,7 @@ SVN本身并不提供这种强制写log的功能,而是通过一系列的钩
270
166
* COVERITY: https://scan.coverity.com/
271
167
* choosealicense: http://choosealicense.com/
272
168
273
- * Reference:http://git-scm.com/docs
274
- * http://git-scm.com/docs/gitignore
275
- * Documentation:http://git-scm.com/doc
276
- * Git book:http://git-scm.com/book/zh/
277
- * Pro Git book(修改自上面):https://git-reference.readthedocs.org/en/latest/
278
- * Git Community Book 中文版:http://gitbook.liuhui998.com/index.html
169
+ * Git Community Book 中文版:< http://gitbook.liuhui998.com/index.html >
279
170
* Permanently remove files and folders from Git repo:http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository
280
171
* git/github初级运用自如:http://www.cnblogs.com/fnng/archive/2012/01/07/2315685.html
281
172
* windows中使用Git工具连接GitHub(配置篇):http://www.cnblogs.com/sorex/archive/2011/08/10/2132359.html
@@ -299,21 +190,7 @@ SVN本身并不提供这种强制写log的功能,而是通过一系列的钩
299
190
* 分支管理策略: < https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013758410364457b9e3d821f4244beb0fd69c61a185ae0000 >
300
191
* Bug分支: < https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137602359178794d966923e5c4134bc8bf98dfb03aea3000 >
301
192
302
- ## install
303
-
304
- * ubuntu:
305
- sudu apt-get install git
306
- * windows:
307
- http://git-scm.com/
308
- https://github.com/dahlbyk/posh-git
309
-
310
- 安装了git后会附带很多linux下常用的工具,比如ssh,scp,curl,split,cat等,很方便。
311
-
312
- ## git项目暂停开发注意事项
313
-
314
- 每次项目暂时结束时,整理工程目录中的文件;保证所有更改均提交到服务器,无本地更改;将本地工程目录压缩;当再次开启该工程时,先从github上clone到本地,解压缩本地文件,对比一些特殊目录,添加必要文件,从新开启该工程。
315
-
316
- ## git init 与 git init --bare
193
+ ### git init 与 git init --bare
317
194
318
195
使用命令"git init --bare"(bare汉语意思是:裸,裸的)初始化的版本库(暂且称为bare repository)只会生成一类文件:用于记录版本库历史记录的.git目录下面的文件;而不会包含实际项目源文件的拷贝;所以该版本库不能称为工作目录(working tree);如果你进入版本目录,就会发现只有.git目录下的文件,而没有其它文件;就是说,这个版本库里面的文件都是.git目录下面的文件,把原本在.git目录里面的文件放在版本库的根目录下面;换句话说,不使用--bare选项时,就会生成.git目录以及其下的版本历史记录文件,这些版本历史记录文件就存放在.git目录下;而使用--bare选项时,不再生成.git目录,而是只生成.git目录下面的版本历史记录文件,这些版本历史记录文件也不再存放在.git目录下面,而是直接存放在版本库的根目录下面。
319
196
@@ -327,23 +204,16 @@ git push origin master:master
327
204
328
205
git push origin master: b1
329
206
330
- 解决办法就是使用”git init –bare”方法创建一个所谓的裸仓库,之所以叫裸仓库是因为这个仓库只保存git历史提交的版本信息,而不允许用户在上面进行各种git操作,如果你硬要操作的话,只会得到下面的错误(”This operation must be run in a work tree”)这个就是最好把远端仓库初始化成bare仓库的原因。
207
+ 解决办法就是使用”git init –bare”方法创建一个所谓的裸仓库,之所以叫裸仓库是因为这个仓库只保存git历史提交的版本信息,而不允许用户在上面进行各种git操作,如果你硬要操作的话,只会得到下面的错误(”This operation must be run in a work tree”)这个就是最好把远端仓库初始化成bare仓库的原因。
331
208
332
-
333
- # Mercurial
209
+ ## Mercurial
334
210
335
211
* Mercurial:https://mercurial.selenic.com/
336
212
* mercurialeclipse: https://bitbucket.org/mercurialeclipse/main/wiki/Home
337
213
* tortoisehg:http://tortoisehg.bitbucket.org/
338
214
215
+ ## Others
339
216
340
- # perforce
341
-
342
- * https://www.perforce.com/
343
-
344
- # Others
345
-
217
+ * perforce: https://www.perforce.com/
346
218
* CVS:http://www.nongnu.org/cvs/
347
- * bazaar:http://bazaar.canonical.com/en/
348
-
349
-
219
+ * bazaar:http://bazaar.canonical.com/en/
0 commit comments