tizen 2.3 release
[framework/multimedia/ffmpeg.git] / doc / git-howto.txt
1
2 About Git write access:
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5 Before everything else, you should know how to use GIT properly.
6 Luckily Git comes with excellent documentation.
7
8   git --help
9   man git
10
11 shows you the available subcommands,
12
13   git <command> --help
14   man git-<command>
15
16 shows information about the subcommand <command>.
17
18 The most comprehensive manual is the website Git Reference
19
20 http://gitref.org/
21
22 For more information about the Git project, visit
23
24 http://git-scm.com/
25
26 Consult these resources whenever you have problems, they are quite exhaustive.
27
28 You do not need a special username or password.
29 All you need is to provide a ssh public key to the Git server admin.
30
31 What follows now is a basic introduction to Git and some FFmpeg-specific
32 guidelines. Read it at least once, if you are granted commit privileges to the
33 FFmpeg project you are expected to be familiar with these rules.
34
35
36
37 I. BASICS:
38 ==========
39
40 0. Get GIT:
41
42   Most distributions have a git package, if not
43   You can get git from http://git-scm.com/
44
45
46 1. Cloning the source tree:
47
48     git clone git://source.ffmpeg.org/ffmpeg <target>
49
50   This will put the FFmpeg sources into the directory <target>.
51
52     git clone git@source.ffmpeg.org:ffmpeg <target>
53
54   This will put the FFmpeg sources into the directory <target> and let
55   you push back your changes to the remote repository.
56
57
58 2. Updating the source tree to the latest revision:
59
60     git pull (--ff-only)
61
62   pulls in the latest changes from the tracked branch. The tracked branch
63   can be remote. By default the master branch tracks the branch master in
64   the remote origin.
65   Caveat: Since merge commits are forbidden at least for the initial
66           months of git --ff-only or --rebase (see below) are recommended.
67           --ff-only will fail and not create merge commits if your branch
68           has diverged (has a different history) from the tracked branch.
69
70 2.a Rebasing your local branches:
71
72     git pull --rebase
73
74   fetches the changes from the main repository and replays your local commits
75   over it. This is required to keep all your local changes at the top of
76   FFmpeg's master tree. The master tree will reject pushes with merge commits.
77
78
79 3. Adding/removing files/directories:
80
81     git add [-A] <filename/dirname>
82     git rm [-r] <filename/dirname>
83
84   GIT needs to get notified of all changes you make to your working
85   directory that makes files appear or disappear.
86   Line moves across files are automatically tracked.
87
88
89 4. Showing modifications:
90
91     git diff <filename(s)>
92
93   will show all local modifications in your working directory as unified diff.
94
95
96 5. Inspecting the changelog:
97
98     git log <filename(s)>
99
100   You may also use the graphical tools like gitview or gitk or the web
101   interface available at http://source.ffmpeg.org
102
103 6. Checking source tree status:
104
105     git status
106
107   detects all the changes you made and lists what actions will be taken in case
108   of a commit (additions, modifications, deletions, etc.).
109
110
111 7. Committing:
112
113     git diff --check
114
115   to double check your changes before committing them to avoid trouble later
116   on. All experienced developers do this on each and every commit, no matter
117   how small.
118   Every one of them has been saved from looking like a fool by this many times.
119   It's very easy for stray debug output or cosmetic modifications to slip in,
120   please avoid problems through this extra level of scrutiny.
121
122   For cosmetics-only commits you should get (almost) empty output from
123
124     git diff -w -b <filename(s)>
125
126   Also check the output of
127
128     git status
129
130   to make sure you don't have untracked files or deletions.
131
132     git add [-i|-p|-A] <filenames/dirnames>
133
134   Make sure you have told git your name and email address, e.g. by running
135     git config --global user.name "My Name"
136     git config --global user.email my@email.invalid
137   (--global to set the global configuration for all your git checkouts).
138
139   Git will select the changes to the files for commit. Optionally you can use
140   the interactive or the patch mode to select hunk by hunk what should be
141   added to the commit.
142
143     git commit
144
145   Git will commit the selected changes to your current local branch.
146
147   You will be prompted for a log message in an editor, which is either
148   set in your personal configuration file through
149
150     git config core.editor
151
152   or set by one of the following environment variables:
153   GIT_EDITOR, VISUAL or EDITOR.
154
155   Log messages should be concise but descriptive. Explain why you made a change,
156   what you did will be obvious from the changes themselves most of the time.
157   Saying just "bug fix" or "10l" is bad. Remember that people of varying skill
158   levels look at and educate themselves while reading through your code. Don't
159   include filenames in log messages, Git provides that information.
160
161   Possibly make the commit message have a terse, descriptive first line, an
162   empty line and then a full description. The first line will be used to name
163   the patch by git format-patch.
164
165
166 8. Renaming/moving/copying files or contents of files:
167
168   Git automatically tracks such changes, making those normal commits.
169
170     mv/cp path/file otherpath/otherfile
171
172     git add [-A] .
173
174     git commit
175
176   Do not move, rename or copy files of which you are not the maintainer without
177   discussing it on the mailing list first!
178
179 9. Reverting broken commits
180
181     git revert <commit>
182
183   git revert will generate a revert commit. This will not make the faulty
184   commit disappear from the history.
185
186     git reset <commit>
187
188   git reset will uncommit the changes till <commit> rewriting the current
189   branch history.
190
191     git commit --amend
192
193   allows to amend the last commit details quickly.
194
195     git rebase -i origin/master
196
197   will replay local commits over the main repository allowing to edit,
198   merge or remove some of them in the process.
199
200   Note that the reset, commit --amend and rebase rewrite history, so you
201   should use them ONLY on your local or topic branches.
202
203   The main repository will reject those changes.
204
205 10. Preparing a patchset.
206
207     git format-patch <commit> [-o directory]
208
209   will generate a set of patches for each commit between <commit> and
210   current HEAD. E.g.
211
212     git format-patch origin/master
213
214   will generate patches for all commits on current branch which are not
215   present in upstream.
216   A useful shortcut is also
217
218     git format-patch -n
219
220   which will generate patches from last n commits.
221   By default the patches are created in the current directory.
222
223 11. Sending patches for review
224
225     git send-email <commit list|directory>
226
227   will send the patches created by git format-patch or directly generates
228   them. All the email fields can be configured in the global/local
229   configuration or overridden by command line.
230   Note that this tool must often be installed separately (e.g. git-email
231   package on Debian-based distros).
232
233 12. Pushing changes to remote trees
234
235     git push
236
237   Will push the changes to the default remote (origin).
238   Git will prevent you from pushing changes if the local and remote trees are
239   out of sync. Refer to 2 and 2.a to sync the local tree.
240
241     git remote add <name> <url>
242
243   Will add additional remote with a name reference, it is useful if you want
244   to push your local branch for review on a remote host.
245
246     git push <remote> <refspec>
247
248   Will push the changes to the remote repository. Omitting refspec makes git
249   push update all the remote branches matching the local ones.
250
251 13. Finding a specific svn revision
252
253   Since version 1.7.1 git supports ':/foo' syntax for specifying commits
254   based on a regular expression. see man gitrevisions
255
256     git show :/'as revision 23456'
257
258   will show the svn changeset r23456. With older git versions searching in
259   the git log output is the easiest option (especially if a pager with
260   search capabilities is used).
261   This commit can be checked out with
262
263     git checkout -b svn_23456 :/'as revision 23456'
264
265   or for git < 1.7.1 with
266
267     git checkout -b svn_23456 $SHA1
268
269   where $SHA1 is the commit SHA1 from the 'git log' output.
270
271
272 Contact the project admins <root at ffmpeg dot org> if you have technical
273 problems with the GIT server.