Git

Version 24 (Gary Bradski, 2013-10-03 05:50 am)

1 13 Gary Bradski
h1. Working with OpenCV git repository.
2 13 Gary Bradski
3 13 Gary Bradski
Git (http://en.wikipedia.org/wiki/Git_(software)) is distributed source code management system, which we now use to develop OpenCV. Therefore, OpenCV developers and contributors should have git installed and learn at least some basics of it. Of course, in the case of a small patch one may simply create a ticket at http://code.opencv.org/projects/opencv/issues and attach the patch there, but our practice shows that going through the pull request mechanism (see [[How to contribute]]) is much more efficient and for that you need git.
4 13 Gary Bradski
5 13 Gary Bradski
h2. Installing Git
6 13 Gary Bradski
7 13 Gary Bradski
* Windows users: take msysgit from http://code.google.com/p/msysgit/downloads/list. Also install "TortoiseGit":http://code.google.com/p/tortoisegit/, a convenient git front-end, which integrates right into Windows Explorer
8 22 Gary Bradski
* Linux users: install command-line git utility using your package manager, e.g. <pre>apt-get install git</pre> on Ubuntu and Debian. You can use "SmartGit":http://www.syntevo.com/smartgithg/index.html as a GUI client. SmartGit is cross-platform, btw.
9 13 Gary Bradski
* Mac users: if you installed Xcode (which you will need anyway), you already have git. You can use "SourceTree":http://www.sourcetreeapp.com/ as a very good GUI client.
10 13 Gary Bradski
11 13 Gary Bradski
h2. Using Git
12 13 Gary Bradski
13 24 Gary Bradski
Most developers and contributors will work with their personal copy (a fork) of OpenCV repository at GitHub. That is, 
14 24 Gary Bradski
* In a browser, go to "the OpenCV repository":https://github.com/Itseez/opencv
15 24 Gary Bradski
* And fork it as described in these Git instruction on "how to fork":https://help.github.com/articles/fork-a-repo
16 24 Gary Bradski
Then, if you use command-line git utility, you can clone the repository to your computer by running:
17 15 Gary Bradski
18 1
<pre>git clone https://github.com/<username>/opencv.git</pre>
19 15 Gary Bradski
20 24 Gary Bradski
where &lt;username&gt; is your login at github. After that you can work on code, submit changes via pull requests, and so on as described at [[How to contribute]].
21 13 Gary Bradski
22 10 Gary Bradski
h1. Instruction for core developers
23 10 Gary Bradski
24 19 Gary Bradski
Most developers should just use github and submit pull requests with their changes. Below are the instructions for the OpenCV maintainers (2-3 people at the moment) who should be able to push changes (or rather merge the pull requests) to the main repository. This is just for reference.
25 17 Gary Bradski
26 16 Gary Bradski
h2. Configuring git
27 10 Gary Bradski
28 10 Gary Bradski
h3. Instruction for Ubuntu users:
29 10 Gary Bradski
30 11 Gary Bradski
* Upload ssh-key to the server. If you haven't created any, do it with the following command: <pre>ssh-keygen -t rsa -f ~/.ssh/id_rsa</pre> Leave the Passphrase empty. Then copy contents of the file  ~/.ssh/id_rsa.pub to the Key field on the  http://code.opencv.org/my/account page. Press Create. Run <pre>ssh-add ~/.ssh/id_rsa</pre> command. It may be critical on some versions of Ubuntu.
31 1
32 5 Gary Bradski
* Clone the repository as described in the section above. Run the following command in local repository folder to be able to push changes
33 5 Gary Bradski
34 5 Gary Bradski
 <pre>git remote set-url origin --push [email protected]:opencv.git</pre>
35 1
36 10 Gary Bradski
h3. Instruction for Windows users:
37 1
38 1
* Download and install an up-to-date version of msysgit from its official site: http://code.google.com/p/msysgit/downloads/list. There is also the portable version (_PortableGit-1.7.11-preview20120710.7z_), which you need only to unpack to get access to the console version of Git. Supposing that for some of us it could be quite enough.
39 21 Gary Bradski
* Download and install the GUI for Git, TortoiseGit or SmartGit
40 1
* Generate SSH access key:
41 1
** Launch Git Bash (file git-bash.bat in msysgit folder).
42 1
** Run <pre>ssh-keygen -t rsa -C  "[email protected]"</pre>  with the console. The output will contain information on where it stored the keys.
43 1
** Go to that directory and open the public key (id_rsa.pub) with any text editor. 
44 1
** Copy contents of the file id_rsa.pub to the Key field on the  http://code.opencv.org/my/account page. Press Create.
45 1
* Clone repository, using 'quick' read-only protocol  (git://code.opencv.org/opencv.git).
46 3 Gary Bradski
* Launch Git Bash again and go to the folder that you've cloned the repository to ('.git' folder should have appeared there). Run the following command: <pre>git remote set-url origin --push [email protected]:opencv.git</pre> to be able to push changes to the repository.
47 1
* That's it. You may try making some changes to commit and push them for the test run.