git-howto.texi 8.6 KB

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