git-howto.texi 8.3 KB

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