EBC Exercise 16 git Workshop Version

git is a distributed revision control system with an emphasis on being fast. It was initially designed and developed by Linus Torvalds for Linux kernel development. The purpose of this lab is to get hands on experience with git to learn how it works and how to use it.

This is the workshop version of the exercise. It assumes git is already installed and the repository is already cloned.

Much of the material here has come from Pro Git. We'll be using github to practice gitting.

Update the git repository
Always before you start work on a git project, make sure you have the current version from github.

beagle$ cd ~/gitLearn beagle$ git pull

Play with git locally

 * Edit  and add a   with your name on it.
 * stage and commit .  You may have to merge.  Keep everyone else's name in the file.
 * Push it to the repository

Here's how it is done.

beagle$ gedit helloWorld.c beagle$ gcc helloWorld.c   Make sure the file compiles and runs OK. beagle$ './a.out beagle$ git status          What's the status of helloWorld? beagle$ git add beagle$ git status          What's the status now? beagle$ git commit -m "Put your own comment here" beagle$ git status          What's the status now? beagle$ git push            This will send your repository to gethub

If the last git push give you error, it means someone else has changed the file on the repository and you need to get the new version before you can push. Do this beagle$ git pull

git will try to merge the new version of the file with your version. It it's successful all you have to do is.

beagle$ gedit helloWord.c   Do this to be sure the file looks OK. beagle$ gcc helloWorld.c beagle$ ./a.out             If it doesn't compile edit and fix it. beagle$ git add beagle$ git commit -m "Another descriptive comment here" beagle$ git push

If you aren't lucky, git won't be able to merge and it will tell you so. Edit the file as above and look for <<<<<<, this will mark the places git didn't know how to handle. Fix them and remove the lines with <<<<<< and repeat the steps above.

If you are lucky, no one else has changed the file while you were working on it. If not, repeat the above steps.

Wait a while and do a git pull to see if anyone else has changed the repository.

Moving from svn
Here's a nice article on a common git workflow for those who are moving from svn.

Other Errors while using git
The BeagleBone might not be able to handle https requests so instead try using git@github.com:repositoryowner/repositoryname.git.

If you run into: error: Problem with the SSL CA cert (path? access rights?) while accessing git@github.com:repositoryowner/repositoryname.git fatal HTTP request failed

You might have to generate a key using ssh-keygen and add it to your SSH keys on your github. To install ssh-keygen do the following: beagle$ opkg install openssh-keygen

Once it is installed or if it is already installed: beagle$ ssh-keygen

It will ask for a file, passphrase, and same passphrase. I just pressed enter and left them blank for all three. This should show up: Generating public/private rsa key pair. Enter file in which to save the key (/home/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/root/.ssh/id_rsa. Your public key has been saved in /home/root/.ssh/id_rsa.pub. The key fingerprint is: a8:08:62:47:72:0a:c0:4f:22:0d:fb:46:59:46:8b:eb root@beaglebone The key's randomart image is: +--[ RSA 2048]+ |+o .+           | |o+.*. | |+.Bo. | |.o=o. | |oo+. . S       | |o+.. .          | |  E. | |                | |                 | +-+

To access the key in the file created by the keygen cat the file using the following command: beagle$ cat ~/.ssh/id_rsa.pub

You should get a long string of characters starting with ssh-rsa and ending with root@beaglebone. Excluding root@beaglebone, this is what you will copy into your SSH-keys on github.com.