Git
How to use git with the papaprazzi master repo.
Contents
Git help and resources
There are tons of tutorials, etc. out there...
You can also get help on any Git command by doing git command -h
or git help command
.
For a quick introduction see the Git crash course for SVN users. For git newbies the Git CheatSheet is also nice.
To get an understanding off the git internals the video Getting Git is excellent.
More:
- git screencasts
- git help from github
- git communitiy book
- ProGit book
- git ready - short tips
- nice Git reference
- more Git cheat sheets
Before You Start
Git is not an evolution of SVN (like SVN is from CVS). This may lead to a lot of extra headscratching among migraters. You have been warned.
Basic Git configuration
First tell git your real name and your e-mail address. You should add these before you start using Git:
git config --global user.name "Your Name" git config --global user.email you@yourdomain.example.com
Set up a Github account
If you want some github awesomeness you have to set up an account there and set your github token. Just go to the webpage and create an account there. Do not forget to upload your ssh key there. Here is a good tutorial on providing your ssh key to GitHub. Otherwise you will not be able to access your repositories.
Get the code
If you plan to contribute or just to push your own config to github please first fork the papaprazzi repo on github. Just log in and click fork at the top of the main paparazzi software repository.
Option 1: clone from your own github repo
If you already forked the paparazzi-software repo to your own github account:
git clone -o <username> git@github.com:<your github username>/paparazzi.git
The option -o <name> uses name to keep track of the upstream repository instead of using the remote name origin. It is recommended to call the remote for the papaprazzi master repo paparazzi and name your own github remote according to your name to avoid confusion.
Adding remotes
Now you want to add the main repo as a remote with the name paparazzi to easily pull changes from there:
git remote add paparazzi git://github.com/paparazzi/paparazzi.git
The above URL provides read-only access, if you are a dev and have write access to the main repo as well you want to use:
git remote add paparazzi git@github.com:paparazzi/paparazzi.git
Option 2: clone from github without an account
Otherwise clone directly from the master repo (read-only):
git clone git://github.com/paparazzi/paparazzi.git
or if you are behind a firewall with an http proxy available:
git clone https://github.com/paparazzi/paparazzi.git
Get to work
Gitk is your friend if you want to visualize all branches and history:
gitk --all
Pull and push
To fetch the changes from the paparazzi master branch on github and merge them into your local branch run
git pull <remote> master
Where <remote> is the name for the remote to the main paparazzi repo and is usually paparazzi or origin.
To push your (already locally committed) changes to your own github master branch
git push <remote> master
Where <remote> is the name for the remote to your own github repo and is <username> if you named it like explained above.
Contribute
It is advisable to do all your work in a branch an then merge back into master when it is ready. Please send us a pull request on github.
Advanced Configuration and helpful tools
If you want to inspect your global configuration, have a look at the .gitconfig file in your home directory.
The per repository configuration is stored in the .git/config file in your repository.
Colors and Aliases
You also might want to set some color options and aliases, e.g.:
git config --global color.ui auto # colors for all git config --global alias.st status # make `git st` work git config --global alias.co checkout # make `git co` work git config --global alias.ci commit # make `git ci` work git config --global alias.br branch # make `git br` work git config --global alias.up "pull --rebase" # make `git up` work similar to svn up
Line endings
Although you might think you’re immune to CRLF-ended files on mac and linux, you are not. It is possible to download files from an external source that use CRLF, and thus commit them into your repo. To be safe, you should set your config to convert line endings on commit so they are always LF in the repo:
git config --global core.autocrlf input
If you are on a windows box by any chance set:
git config --global core.autocrlf true
Magit
If you are an emacs user you might want to have a look at http://philjackson.github.com/magit/
git status in shell
For bash: http://www.gitready.com/advanced/2009/01/23/bash-git-status.html
For zsh: http://www.wunjo.org/zsh-git/