author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sat, 25 Nov 2017 23:59:29 +0200 | |
changeset 2207 | 5085ac83075b |
parent 2195 | 3556ec0e48be |
child 2209 | 6faf149a4f4c |
permissions | -rw-r--r-- |
1002 | 1 |
.. -*- coding: utf-8; -*- |
2 |
||
3 |
====== |
|
4 |
Git. |
|
5 |
====== |
|
1032
4decc3e00bb6
Fix coding and contents.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1002
diff
changeset
|
6 |
.. contents:: |
1905
fba288d59662
Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1815
diff
changeset
|
7 |
:local: |
1002 | 8 |
|
2101 | 9 |
Setting up git |
10 |
============== |
|
1002 | 11 |
|
2101 | 12 |
Debian:: |
1002 | 13 |
|
2081
0d9703b4a428
Remove outdated data. Fix formatting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1932
diff
changeset
|
14 |
$ sudo apt-get install git |
1002 | 15 |
|
2101 | 16 |
Cygwin:: |
17 |
||
18 |
$ setup.exe -p git |
|
19 |
$ apt-cyg install git |
|
20 |
||
21 |
After install set up some options:: |
|
1002 | 22 |
|
23 |
$ git config --global user.name "Oleksandr Gavenko" |
|
24 |
$ git config --global user.mail "gavenkoa@gmail.com" |
|
2101 | 25 |
|
26 |
After that you should have:: |
|
27 |
||
1002 | 28 |
$ cat ~/.gitconfig |
29 |
[user] |
|
2101 | 30 |
name = Oleksandr Gavenko |
31 |
mail = gavenkoa@gmail.com |
|
1002 | 32 |
|
33 |
git over proxy. |
|
34 |
=============== |
|
35 |
||
36 |
Only http:// protocol support proxy (not git://):: |
|
37 |
||
38 |
$ export http_proxy="http://username:password@proxy:port/" |
|
39 |
$ git clone http://github.com/$user/$proj.git $proj |
|
40 |
||
41 |
You can store proxy settings under repository local config file:: |
|
42 |
||
43 |
$ git config http.proxy http://$user:$passwd@$ip:$port |
|
44 |
||
2081
0d9703b4a428
Remove outdated data. Fix formatting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1932
diff
changeset
|
45 |
Start project with git |
0d9703b4a428
Remove outdated data. Fix formatting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1932
diff
changeset
|
46 |
====================== |
1002 | 47 |
|
48 |
Setup proj space on fs:: |
|
49 |
||
50 |
$ mkdir proj |
|
51 |
$ cd proj |
|
52 |
$ git init |
|
53 |
Initialized empty Git repository in /home/user/tmp/proj/.git/ |
|
54 |
$ ls -a |
|
55 |
. .. .git |
|
56 |
||
57 |
Add file, make changes, commit all:: |
|
58 |
||
59 |
$ emacs Makefile |
|
60 |
... C-x C-c |
|
61 |
$ emacs app.c |
|
62 |
... C-x C-c |
|
63 |
$ git add Makefile app.c |
|
64 |
$ git status |
|
65 |
# On branch master |
|
66 |
# |
|
67 |
# Initial commit |
|
68 |
# |
|
69 |
# Changes to be committed: |
|
70 |
# (use "git rm --cached <file>..." to unstage) |
|
71 |
# |
|
72 |
# new file: Makefile |
|
73 |
# new file: app.c |
|
74 |
# |
|
75 |
||
76 |
or just:: |
|
77 |
||
78 |
$ git add . |
|
79 |
||
80 |
Commit newlly added file:: |
|
81 |
||
82 |
$ git commit |
|
83 |
... Write message log ... |
|
84 |
Created initial commit 2169263: My first commit massage. |
|
85 |
1 files changed, 4 insertions(+), 0 deletions(-) |
|
86 |
create mode 100644 app.c |
|
87 |
||
88 |
Undo tracking added file. |
|
89 |
========================= |
|
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 |
||
2082
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
117 |
Committing changes |
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
118 |
================== |
1002 | 119 |
|
2082
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
120 |
Individual file:: |
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
121 |
|
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
122 |
$ $EDITOR Makefile |
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
123 |
$ git add Makefile |
2152
a48ba30d5b20
Fixed example for done changes review.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2126
diff
changeset
|
124 |
$ git diff --cached |
2082
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
125 |
$ git commit -m "..." |
1002 | 126 |
|
2082
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
127 |
Commit all changed and previously manages files:: |
1002 | 128 |
|
2082
7f6ce6b18a0c
Remove unnecessary details.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2081
diff
changeset
|
129 |
$ git commit -a -m "...." |
1002 | 130 |
|
2084 | 131 |
Managing branches |
132 |
================= |
|
133 |
||
134 |
Print current branch:: |
|
135 |
||
136 |
$ git branch |
|
137 |
||
138 |
List all known branches:: |
|
139 |
||
140 |
$ git branch -a |
|
141 |
||
142 |
List all known remote branches:: |
|
143 |
||
144 |
$ git branch -r |
|
145 |
||
146 |
List all remote branches (from all remotes):: |
|
147 |
||
148 |
$ git ls-remote |
|
2190 | 149 |
$ git ls-remote origin |
150 |
||
151 |
List registered remotes:: |
|
152 |
||
153 |
$ git remote show |
|
2084 | 154 |
|
155 |
List remote branches from ``$REMOTE`` remote:: |
|
156 |
||
157 |
$ git ls-remote --heads $REMOTE |
|
158 |
$ git remote show $REMOTE |
|
159 |
||
2190 | 160 |
Special case of above is ``origin`` remote, which is default remote:: |
161 |
||
162 |
$ git remote show origin |
|
163 |
$ git ls-remote --heads origin |
|
164 |
||
2084 | 165 |
.. note:: |
166 |
||
167 |
Look to ``[remote "..."]`` in ``~/.git/config`` to find out names of possible |
|
168 |
remotes. Alternatively get list from:: |
|
169 |
||
170 |
$ git remote show |
|
171 |
||
2190 | 172 |
Getting branches pointers from default (``origin``) remote (without merging |
173 |
tracking branch):: |
|
2084 | 174 |
|
175 |
$ git fetch |
|
176 |
||
177 |
Getting branches pointers from ``$REMOTE`` remote:: |
|
178 |
||
179 |
$ git fetch $REMOTE |
|
180 |
||
2190 | 181 |
To get updated with default remote changes:: |
182 |
||
183 |
$ git pull |
|
184 |
||
185 |
or specify concrete remote:: |
|
186 |
||
187 |
$ git pull $REMOTE |
|
188 |
$ git pull origin |
|
189 |
||
190 |
To locally remove pointers to deleted remotely branches:: |
|
191 |
||
192 |
$ git remote update --prune |
|
193 |
$ git remote update --prune origin |
|
194 |
||
2084 | 195 |
.. note:: |
196 |
||
197 |
Only curtain branches fetched by default:: |
|
198 |
||
199 |
[remote "origin"] |
|
2123
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
200 |
url = ... |
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
201 |
fetch = +refs/heads/*:refs/remotes/origin/* |
2084 | 202 |
|
203 |
Edit ``fetch`` value to change defaults. |
|
204 |
||
2171
2ded7f1cf6c0
Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2153
diff
changeset
|
205 |
Move branch pointer to arbitrary hash:: |
2ded7f1cf6c0
Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2153
diff
changeset
|
206 |
|
2ded7f1cf6c0
Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2153
diff
changeset
|
207 |
$ git branch -f $NAME $HASH |
2ded7f1cf6c0
Move branch pointer to arbitrary hash.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2153
diff
changeset
|
208 |
|
2085
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
209 |
git analog of 'hg incoming' |
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
210 |
=========================== |
1002 | 211 |
|
212 |
git does not directly support such feature. You can emulate it by:: |
|
213 |
||
214 |
$ git fetch |
|
215 |
$ git log master..origin/master # or just '..origin/master' |
|
216 |
||
2085
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
217 |
By previous commands you grab changes from remote server! You can apply them by |
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
218 |
``pull`` or ``merge`` or ``rebase`` command:: |
1002 | 219 |
|
2085
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
220 |
$ git pull |
1002 | 221 |
$ git merge |
2085
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
222 |
TODO |
1002 | 223 |
|
2085
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
224 |
To detect if remote repository have new changes:: |
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
225 |
|
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
226 |
$ git ls-remote |
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
227 |
$ git ls-remote $upstream |
652aca73fc06
Detect if remote repository have new changes.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2084
diff
changeset
|
228 |
|
2126 | 229 |
View git commits |
230 |
================ |
|
231 |
||
232 |
Review specific commit with:: |
|
233 |
||
234 |
$ git show $REV |
|
235 |
$ git diff $REV^ $REV |
|
236 |
||
237 |
Review difference between commits:: |
|
238 |
||
239 |
$ git $REV1 $REV2 |
|
2153
e88e36e73ebc
Review difference between commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2152
diff
changeset
|
240 |
$ git $REV1..$REV2 |
e88e36e73ebc
Review difference between commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2152
diff
changeset
|
241 |
$ git $REV1..$REV2 -- $DIR_OR_FILE |
2126 | 242 |
|
243 |
Review history with diffs:: |
|
244 |
||
245 |
$ git log -p |
|
246 |
$ git log -p $FROM_REV |
|
247 |
||
2122
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
248 |
View unpublished git commits / analog of git 'hg outgoing' |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
249 |
========================================================== |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
250 |
|
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
251 |
``git`` does not directly support such feature. Recently ``hg`` start tracking |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
252 |
changes that pushed to any other repositories (called as ``public`` versus |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
253 |
``draft`` which is not yet published anywhere). You can emulate it by:: |
1002 | 254 |
|
2122
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
255 |
$ git fetch origin |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
256 |
$ git log origin/master..master |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
257 |
$ git log origin/master.. |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
258 |
$ git log origin/master..HEAD |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
259 |
$ git log @{u}.. |
1002 | 260 |
|
2122
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
261 |
$ git diff origin/master.. |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
262 |
|
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
263 |
Verbose syntax:: |
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
264 |
|
24fbab64cf91
View unpublished git commits.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2116
diff
changeset
|
265 |
$ git log --branches --not --remotes |
1002 | 266 |
|
2123
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
267 |
http://stackoverflow.com/questions/2016901/viewing-unpushed-git-commits |
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
268 |
Viewing unpushed Git commits. |
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
269 |
http://stackoverflow.com/questions/3636914/how-can-i-see-what-i-am-about-to-push-with-git |
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
270 |
How can I see what I am about to push with git? |
f98c2b2e6c07
View unpublished git commits- added links.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2122
diff
changeset
|
271 |
|
2102
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
272 |
git analog of 'hg glog' |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
273 |
======================= |
1650
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
274 |
:: |
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
275 |
|
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
276 |
$ git log --all --graph |
2102
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
277 |
$ git log --all --graph --oneline |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
278 |
$ git log --all --graph --oneline --decorate |
1650
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
279 |
|
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
280 |
Add alias:: |
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
281 |
|
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
282 |
[alias] |
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
283 |
glog = log --all --graph |
a48c3c61d0f9
git analog of 'hg glog'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1641
diff
changeset
|
284 |
|
2116 | 285 |
Git analog of 'hg rollback' |
286 |
=========================== |
|
1651
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
287 |
|
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
288 |
To edit commit message of last commit:: |
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
289 |
|
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
290 |
$ git commit --amend -m "$MSG" |
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
291 |
|
2116 | 292 |
To integrate changes into last commit (``-a`` to avoid antecedent ``git add ...``, |
293 |
``--no-edit`` if you don't like to change commit message, otherwise external |
|
294 |
editor is opened):: |
|
295 |
||
296 |
$ git commit -a --amend --no-edit |
|
297 |
||
1651
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
298 |
To edit messages of old commits starting from ``$REV``:: |
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
299 |
|
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
300 |
$ git rebase -i $REV |
c77807176b36
Git analog of 'hg rollback'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1650
diff
changeset
|
301 |
|
2124 | 302 |
To undo latest commit:: |
303 |
||
304 |
$ git reset HEAD~1 |
|
305 |
||
2102
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
306 |
Git analog of 'hg root' |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
307 |
======================= |
1771
b2d4be61da16
Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1714
diff
changeset
|
308 |
:: |
b2d4be61da16
Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1714
diff
changeset
|
309 |
|
b2d4be61da16
Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1714
diff
changeset
|
310 |
$ git rev-parse --show-toplevel |
b2d4be61da16
Git analog of 'hg root'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1714
diff
changeset
|
311 |
|
2102
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
312 |
Making local branch tracking remote |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
313 |
=================================== |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
314 |
:: |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
315 |
|
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
316 |
$ git branch -u upstream/foo |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
317 |
$ git branch -u upstream/foo foo |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
318 |
|
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
319 |
$ git branch --set-upstream-to=upstream/foo |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
320 |
$ git branch --set-upstream-to=upstream/foo foo |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
321 |
|
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
322 |
Showing what and how local branches are tracked:: |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
323 |
|
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
324 |
$ git branch -vv |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
325 |
$ cat .git/gitconfig |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
326 |
|
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
327 |
Showing what remote branches tracked:: |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
328 |
|
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
329 |
$ git remote show $remote |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
330 |
|
2115
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
331 |
Undo mistaken rebase |
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
332 |
==================== |
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
333 |
|
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
334 |
If there are no any ``reset``, ``rebase`` or ``merge`` afterwards the easiest |
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
335 |
way to recode to pre-rebase state is one of:: |
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
336 |
|
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
337 |
$ git rebase --abort |
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
338 |
$ git reset --hard ORIG_HEAD |
0263a79eeb3b
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2102
diff
changeset
|
339 |
|
2172
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
340 |
Otherwise look to:: |
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
341 |
|
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
342 |
$ git reflog |
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
343 |
|
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
344 |
and reset to necessary head:: |
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
345 |
|
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
346 |
$ git reset --hard "HEAD@{...}" |
850d2d84e4c8
Undo mistaken rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2171
diff
changeset
|
347 |
|
2173
69aed373ceb9
Undoing git rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2172
diff
changeset
|
348 |
https://stackoverflow.com/questions/134882/undoing-a-git-rebase |
69aed373ceb9
Undoing git rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2172
diff
changeset
|
349 |
Undoing git rebase. |
69aed373ceb9
Undoing git rebase.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2172
diff
changeset
|
350 |
|
2179 | 351 |
Undo reset --hard |
352 |
================= |
|
353 |
||
354 |
``git reset --hard`` is destructive command without backup data. |
|
355 |
||
356 |
You may find your previously added data in Git garbage:: |
|
357 |
||
358 |
$ git fsck --lost-found |
|
359 |
||
360 |
look to files inside ``.git/lost-found`` directory. |
|
361 |
||
362 |
Reviewing ``git reflog`` also may help. |
|
363 |
||
364 |
* https://stackoverflow.com/questions/5788037/recover-from-git-reset-hard |
|
365 |
* https://stackoverflow.com/questions/14251194/how-to-recover-after-i-execute-git-reset-hard-head |
|
366 |
||
2175 | 367 |
Git bisect |
368 |
========== |
|
369 |
||
2176 | 370 |
``bad`` changes should be later in graph history then ``good`` ones. To use |
371 |
alternative names:: |
|
372 |
||
373 |
$ git start --term-old=... --term-new=... |
|
2175 | 374 |
|
375 |
Start bisecting with:: |
|
376 |
||
377 |
$ git bisect start |
|
378 |
||
379 |
Mark good and bad revisions:: |
|
380 |
||
381 |
$ git co vBAD |
|
382 |
$ make test |
|
383 |
$ git bisect bad |
|
384 |
||
385 |
$ git co vGOOD |
|
386 |
$ make test |
|
387 |
$ git bisect good |
|
388 |
||
389 |
||
390 |
If build/test failed to complete use:: |
|
391 |
||
392 |
$ git bisect skip |
|
393 |
||
394 |
To restore mistakenly marked revisions:: |
|
395 |
||
396 |
$ git bisect log >$LOG |
|
397 |
$ git bisect reset |
|
398 |
$ $EDITOR $LOG |
|
399 |
$ git bisect replay $LOG |
|
400 |
||
2102
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
401 |
Debug git network operation |
ce5d8887b874
Making local branch tracking remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2101
diff
changeset
|
402 |
=========================== |
1002 | 403 |
|
404 |
Git uses libcurl for network operation:: |
|
405 |
||
406 |
$ export GIT_CURL_VERBOSE=1 |
|
407 |
$ git ... |
|
408 |
||
1076
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
409 |
Push new repo to remote. |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
410 |
======================== |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
411 |
:: |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
412 |
|
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
413 |
$ mkdir $REPO |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
414 |
$ cd $REPO |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
415 |
$ git init |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
416 |
$ git add . |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
417 |
$ git commit -m "Initial commit" |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
418 |
$ git remote add origin https://$USER:$PASS@$HOST/$REPO |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
419 |
$ git push -u origin master |
9b2eb3c96d84
Push new repo to remote.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1032
diff
changeset
|
420 |
|
1641
04e215a475e0
Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
421 |
Show heads in branch. |
04e215a475e0
Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
422 |
===================== |
04e215a475e0
Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
423 |
:: |
04e215a475e0
Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
424 |
|
04e215a475e0
Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
425 |
$ git show-ref --heads -s |
04e215a475e0
Show heads in branch.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
426 |
|
1932
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
427 |
Search string in file |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
428 |
===================== |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
429 |
|
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
430 |
To search string in all or specific files or working copy:: |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
431 |
|
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
432 |
$ git grep $PATT |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
433 |
$ git grep -i $PATT -- '*.[ch]' |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
434 |
|
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
435 |
To search in all history:: |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
436 |
|
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
437 |
$ git log -S$PATT |
2195
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
438 |
$ git log --pickaxe-regex=$PATT |
1932
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
439 |
$ git log -G$PATT |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
440 |
$ git grep -i PATT $(git rev-list --all) -- '*.[ch]' |
6b987b040e18
Search string in file
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
441 |
|
2195
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
442 |
.. note:: |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
443 |
|
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
444 |
``-S`` search occurences in diff chunks, while ``-G`` detects changes in match count. |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
445 |
|
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
446 |
https://git-scm.com/book/en/v2/Git-Tools-Searching |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
447 |
Git Tools - Searching. |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
448 |
https://stackoverflow.com/questions/1337320/how-to-grep-git-commit-diffs-or-contents-for-a-certain-word |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
449 |
How to grep Git commit diffs or contents for a certain word? |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
450 |
https://stackoverflow.com/questions/4468361/search-all-of-git-history-for-a-string |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
451 |
Search all of Git history for a string? |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
452 |
https://stackoverflow.com/questions/2928584/how-to-grep-search-committed-code-in-the-git-history |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
453 |
How to grep (search) committed code in the git history? |
3556ec0e48be
Search string in file.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
2190
diff
changeset
|
454 |
|
1089
2c23dfe7517e
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1076
diff
changeset
|
455 |
Find most recent tag for revision. |
2c23dfe7517e
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1076
diff
changeset
|
456 |
================================== |
2c23dfe7517e
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1076
diff
changeset
|
457 |
:: |
2c23dfe7517e
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1076
diff
changeset
|
458 |
|
2c23dfe7517e
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1076
diff
changeset
|
459 |
$ git describe $REV |
2c23dfe7517e
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1076
diff
changeset
|
460 |
|
1815
49fb4309d4d0
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1771
diff
changeset
|
461 |
Many projects set tags on branches rather then mainline (for example JS/CSS |
49fb4309d4d0
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1771
diff
changeset
|
462 |
projects perform build and commit binary/minified files, which unnecessary for |
49fb4309d4d0
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1771
diff
changeset
|
463 |
mainline history). In this case review simplifiied history by:: |
49fb4309d4d0
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1771
diff
changeset
|
464 |
|
49fb4309d4d0
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1771
diff
changeset
|
465 |
$ git log --graph --all --decorate --oneline --simplify-by-decoration |
49fb4309d4d0
Find most recent tag for revision.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1771
diff
changeset
|
466 |
|
1714
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
467 |
List tags with dates. |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
468 |
===================== |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
469 |
:: |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
470 |
|
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
471 |
$ git log --tags --simplify-by-decoration --pretty="format:%ci %d" |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
472 |
|
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
473 |
Update to date. |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
474 |
=============== |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
475 |
:: |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
476 |
|
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
477 |
$ git checkout 'master@{1979-02-26}' |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
478 |
$ git checkout 'master@{1979-02-26 18:30:00}' |
eed8cfffa44e
List tags with dates.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1651
diff
changeset
|
479 |
|
1002 | 480 |
Using git to work with SVN offline. |
481 |
=================================== |
|
482 |
||
483 |
Prepare SVN and git utilities:: |
|
484 |
||
485 |
$ sudo apt-get svn git-core git-svn |
|
486 |
||
487 |
Making SVN repo:: |
|
488 |
||
489 |
$ cd $HOME/tmp |
|
490 |
$ svnadmin create svn-repo |
|
491 |
$ svn co file://$HOME/tmp/svn-repo svn-devel |
|
492 |
$ cd svn-devel |
|
493 |
$ mkdir tags trunk branches |
|
494 |
$ svn add * |
|
495 |
A branches |
|
496 |
A tags |
|
497 |
A trunk |
|
498 |
$ cd trunk/ |
|
499 |
$ printf "all:\n echo XXX\n" >Makefile |
|
500 |
$ printf "int main() {return 0;}" >main.c |
|
501 |
$ svn add * |
|
502 |
$ cd .. |
|
503 |
$ svn st |
|
504 |
A trunk |
|
505 |
A trunk/main.c |
|
506 |
A trunk/Makefile |
|
507 |
A branches |
|
508 |
A tags |
|
509 |
$ svn ci -m init |
|
510 |
Adding branches |
|
511 |
Adding tags |
|
512 |
Adding trunk |
|
513 |
Adding trunk/Makefile |
|
514 |
Adding trunk/main.c |
|
515 |
Transmitting file data .. |
|
516 |
$ svn cp -m v0.0 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/tags/v0.0 |
|
517 |
$ svn cp -m v0.1 file://$HOME/tmp/svn/trunk file://$HOME/tmp/svn/branches/v0.1 |
|
518 |
||
519 |
Moving SVN changset to git repo:: |
|
520 |
||
521 |
$ cd $HOME/tmp |
|
522 |
$ git svn init file://$HOME/tmp/svn git-repo |
|
523 |
$ ls -a |
|
524 |
. .. .git |
|
525 |
$ git svn fetch |
|
526 |
A trunk/main.c |
|
527 |
A trunk/Makefile |
|
528 |
W: +empty_dir: branches |
|
529 |
W: +empty_dir: tags |
|
530 |
r1 = 52ccd9882979dd53ec198dbac108783ec660410f (git-svn) |
|
531 |
A tags/v0.0/main.c |
|
532 |
A tags/v0.0/Makefile |
|
533 |
r2 = 8ec8a772bb6f37ace56b3649066dc84e481ed427 (git-svn) |
|
534 |
M trunk/Makefile |
|
535 |
r3 = 2c169ff409ed504dd6a092b1e302beb3fd94871e (git-svn) |
|
536 |
A branches/v0.1/main.c |
|
537 |
A branches/v0.1/Makefile |
|
538 |
r4 = e68d76f4ba6beea4b9059c1884c1f38ce10831a7 (git-svn) |
|
539 |
M trunk/Makefile |
|
540 |
r5 = cdde63974454b13ac53f2eeb201aa76c49fd875c (git-svn) |
|
541 |
Checked out HEAD: |
|
542 |
file:///home/sasha/tmp/svn r5 |
|
543 |
||
544 |
or (in old git version):: |
|
545 |
||
546 |
$ git svn clone file://$HOME/tmp/svn git-repo |
|
547 |
||
548 |
Making changes in svn:: |
|
549 |
||
550 |
$ cd $HOME/tmp/svn-devel/trunk |
|
551 |
$ echo ".PHONY: clean" >>Makefile |
|
552 |
$ svn ci -m "Added clean to phony." |
|
553 |
Sending trunk/Makefile |
|
554 |
Transmitting file data . |
|
555 |
Committed revision 6. |
|
556 |
||
557 |
Making committed in git:: |
|
558 |
||
559 |
$ cd $HOME/tmp/git-repo/trunk |
|
560 |
$ echo ".PHONY: all" >>Makefile |
|
561 |
$ echo "int foo(int x) {return x+x;}" >>main.c |
|
562 |
$ git status |
|
563 |
# On branch master |
|
564 |
# Changed but not updated: |
|
565 |
# (use "git add <file>..." to update what will be committed) |
|
566 |
# |
|
567 |
# modified: Makefile |
|
568 |
# modified: main.c |
|
569 |
# |
|
570 |
no changes added to commit (use "git add" and/or "git commit -a") |
|
571 |
$ git commit -a -m "Bug fixed." |
|
572 |
Created commit 222d399: Bug fixed. |
|
573 |
2 files changed, 2 insertions(+), 0 deletions(-) |
|
574 |
||
575 |
Getting changes from SVN to git:: |
|
576 |
||
577 |
$ git svn rebase |
|
578 |
M trunk/Makefile |
|
579 |
r6 = 8165e9bfb38e9df09a7313d19606ec227629b670 (git-svn) |
|
580 |
First, rewinding head to replay your work on top of it... |
|
581 |
Applying Bug fixed. |
|
582 |
error: patch failed: trunk/Makefile:6 |
|
583 |
error: trunk/Makefile: patch does not apply |
|
584 |
Using index info to reconstruct a base tree... |
|
585 |
Falling back to patching base and 3-way merge... |
|
586 |
Auto-merged trunk/Makefile |
|
587 |
CONFLICT (content): Merge conflict in trunk/Makefile |
|
588 |
Failed to merge in the changes. |
|
589 |
Patch failed at 0001. |
|
590 |
||
591 |
When you have resolved this problem run "git rebase --continue". |
|
592 |
If you would prefer to skip this patch, instead run "git rebase --skip". |
|
593 |
To restore the original branch and stop rebasing run "git rebase --abort". |
|
594 |
||
595 |
rebase refs/remotes/git-svn: command returned error: 1 |
|
596 |
$ git add Makefile |
|
597 |
$ git rebase --continue |
|
598 |
Applying Bug fixed. |
|
599 |
||
600 |
and return all from git to SVN:: |
|
601 |
||
602 |
$ git svn dcommit |
|
603 |
Committing to file:///home/sasha/tmp/svn ... |
|
604 |
M trunk/Makefile |
|
605 |
M trunk/main.c |
|
606 |
Committed r7 |
|
607 |
M trunk/main.c |
|
608 |
M trunk/Makefile |
|
609 |
r7 = 68e782c8d06635f2db4dd69b9ca8599f99da22e2 (git-svn) |
|
610 |
No changes between current HEAD and refs/remotes/git-svn |
|
611 |
Resetting to the latest refs/remotes/git-svn |
|
612 |
||
613 |
See what going to SVN repo:: |
|
614 |
||
615 |
$ cd $HOME/tmp/svn-devel/trunk |
|
616 |
$ svn diff -r BASE:HEAD |
|
617 |
Index: Makefile |
|
618 |
=================================================================== |
|
619 |
--- Makefile (working copy) |
|
620 |
+++ Makefile (revision 7) |
|
621 |
@@ -6,4 +6,4 @@ |
|
622 |
.o: .c |
|
623 |
$(CC) $(CFLAGS) -c -o $@ $< |
|
624 |
||
625 |
-.PHONY: clean |
|
626 |
+.PHONY: all clean |
|
627 |
Index: main.c |
|
628 |
=================================================================== |
|
629 |
--- main.c (working copy) |
|
630 |
+++ main.c (revision 7) |
|
631 |
@@ -2,3 +2,4 @@ |
|
632 |
{ |
|
633 |
return 0; |
|
634 |
} |
|
635 |
+int foo(int x) {return x+x;} |
|
636 |
$ svn up |
|
637 |
U Makefile |
|
638 |
U main.c |
|
639 |
Updated to revision 7. |
|
640 |
||
641 |
gitk. |
|
642 |
===== |
|
643 |
||
644 |
gitk - The git repository browser. See gitk(1). |
|
645 |
||
646 |
Installing:: |
|
647 |
||
648 |
$ sudo apt-get instal gitk |
|
649 |
||
650 |
Using:: |
|
651 |
||
652 |
$ cd /path/to/git-repo |
|
653 |
$ gitk |
|
654 |