git-howto.txt 7.9 KB

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