Project

General

Profile

GitSvn » History » Version 5

Andreas Kohlbecker, 10/11/2012 10:32 AM

1 1 Andreas Kohlbecker
2
3
## Git Svn workflow and cheat sheet
4 2 Andreas Kohlbecker
5
6 3 Andreas Kohlbecker
 **NOTE: this page is still under construction - no guarantee for correctness ( not yet ).** 
7
8
9
10
### External references and other links
11
 
12 1 Andreas Kohlbecker
13 4 Andreas Kohlbecker
* https://git.wiki.kernel.org/images-git/7/78/Git-svn-cheatsheet.pdf
14
15
* http://myhumblecorner.wordpress.com/2011/08/25/git-svn-cheatsheet-for-git-rebels-in-an-svn-workplace/
16 3 Andreas Kohlbecker
17
18 2 Andreas Kohlbecker
19
### cloning and EDIT svn repo
20
 
21
22
Clone a svn sub-repository. It is important to specify the sub folders in trunk branches and tags!!
23
24
Here the subrepo drupal is used in the example:
25
26
27
~~~
28
 git svn clone -T trunk/drupal -t tags/drupal -b branches/drupal http://dev.e-taxonomy.eu/svn ./
29
~~~
30
31
create git ignore:
32
33
~~~
34
git-svn show-ignore > .gitignore
35
~~~
36
37
38
### reference on git/svn command equivalents
39
 
40
41
* svn up => git svn rebase
42
43
* svn commit => git svn dcommit (will commit latest commits in git to the svn repository
44
45
46
47
### revering via reset
48
 
49
 whipe out all changes in working directory, and replace with HEAD revision
50
51
~~~
52
git reset --hard HEAD 
53
~~~
54
55
56
### resolving merge conflicts
57
 
58
~~~
59
 git mergetool
60
~~~
61
62
#### keep either file in merge conflicts
63
64
65
There’s two unmerged files here. According to the git checkout manpage, there’s a --theirs and --ours options on the command. The former will keep the version of the file that you merged in, and the other will keep the original one we had.
66
67
68
The following commands will keep the original file for index.html, and then use the merged in file only for _layouts/default.html.
69
70
~~~
71
git checkout --ours filename.c
72
git checkout --theirs filename.c
73
git add filename.c
74
git commit -m "using theirs"
75
~~~
76 5 Andreas Kohlbecker
77
78
### reintegrating an svn branch
79
80
~~~
81
git checkout <merge-to branch>; git merge --squash <merge-from branch>; git commit; git svn dcommit # --squash is key
82
~~~
83
84
delete or lock the branch afterwards!
85
86
87
88
### lock an svn branch
89
90
91
not equivalent in git, thus you need to use svn for it.
92
93
94
95
checkout:
96
97
~~~
98
svn co http://dev.e-taxonomy.eu/svn/branches/mybranch
99
~~~
100
101
102
lock in zsh with
103
104
~~~
105
svn lock <root>/**/*(.) 
106
~~~
107
in bash with
108
109
~~~
110
 find <root> -type f | xargs svn lock
111
~~~
112
113
commit the changes:
114
115
~~~
116
svn commit -m "branch locked"
117
~~~