Difference between revisions of "Git"

From PaparazziUAV
Jump to: navigation, search
(updated git info for switch that will happen soon)
Line 1: Line 1:
How to use [http://git-scm.com/ git] to commit to the paparazzi git repository.
+
<span style="color:red"><strong><big>We will switch to git on 19.11.2010, the git repo might be changed/moved/deleted until then, best stick to SVN until then!</big></strong></span>
 +
 
 +
----
  
See [https://git.wiki.kernel.org/index.php/GitSvnCrashCourse Git - crash course] for an introduction into git for svn users. For git newbies the [https://git.wiki.kernel.org/index.php/GitCheatSheet Git CheatSheet] is also nice.
 
  
To get an understanding off the git internals the [http://blip.tv/file/4094854 video Getting Git] is excellent.
+
How to use [http://git-scm.com/ git] with the [http://github.com/paparazzi/paparazzi-software/ papaprazzi-software master repo].
  
 
== Git help and resources ==
 
== Git help and resources ==
Line 14: Line 15:
  
 
More:
 
More:
 +
* [http://help.github.com/ git help from github]
 
* [http://book.git-scm.com/index.html git communitiy book]
 
* [http://book.git-scm.com/index.html git communitiy book]
 
* [http://progit.org/book/ ProGit book]
 
* [http://progit.org/book/ ProGit book]
Line 20: Line 22:
  
 
== Before You Start ==
 
== 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.
  
Git is not an evolution of SVN (like SVN is from CVS). This mayo lead to a lot of extra headscratching among migraters.  You have been warned.
+
=== Basic Git configuration ===
 
 
=== Configuring Git ===
 
 
 
 
First tell git your ''real name'' and your ''e-mail address''.  You should add these before you start using Git:
 
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.name ''"Your Name"''
 
  git config --global user.email ''you@yourdomain.example.com''
 
  git config --global user.email ''you@yourdomain.example.com''
 
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
 
 
If you want to inspect your configuration work have a look at your '''.git/config''' file.
 
  
 
=== Set up a Github account ===
 
=== Set up a Github account ===
Line 44: Line 34:
  
 
== Get the code ==
 
== Get the code ==
=== Clone from Github ===
+
If you plan to contribute or just to push your own config to github '''please first fork the [http://github.com/paparazzi/paparazzi-software/ papaprazzi-software repo] on github'''.
If you want to push to your own repository on github please first fork the [http://github.com/paparazzi/paparazzi3/ main paparazzi repo] there. Then clone from your repo on github:
+
Just log in and click fork at the top of the main paparazzi-software repo.
  git clone -o <username> git@github.com:<your github username>/paparazzi3.git
+
 
 +
=== 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-software.git
  
Otherwise clone directly from the [http://github.com/paparazzi/paparazzi3/ master repo] (read-only):
+
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.
git clone -o github git://github.com/paparazzi/paparazzi3.git
 
  
Or if you are a dev with write access (and don't want to use your own github repo as well) use:
+
==== Adding remotes ====
  git clone -o github git@github.com:paparazzi/paparazzi3.git
+
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-software.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-software.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 ''github'' and name your own github remote according to your name to avoid confusion.
+
=== Option 2: clone from github without an account ===
 +
Otherwise clone directly from the [http://github.com/paparazzi/paparazzi-software/ master repo] (read-only):
 +
git clone git://github.com/paparazzi/paparazzi-software.git
  
=== Adding remotes ===
+
== Get to work ==
Assuming for example that you forked the paparazzi master repo directly on github and cloned from your own github repo as explained by the first option above you want to add the master repo as a remote with the name ''github'':
+
Gitk is your friend if you want to visualize all branches and history:
  git remote add github git://github.com/paparazzi/paparazzi3.git
+
  gitk --all
That URL provides read-only access, if you are a dev and have write access to the master repo as well you want to use
 
git remote add github git@github.com:paparazzi/paparazzi3.git
 
  
 
=== Pull and push ===
 
=== Pull and push ===
 +
To fetch the changes from the paparazzi master branch on github merge them run
 +
git pull paparazzi
 +
 +
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 ===
 +
Please send us a pull request on github.
  
To get the changes from the master branch on github run
+
== Advanced Configuration and helpful tools ==
git fetch github
+
If you want to inspect your global configuration, have a look at the '''.gitconfig''' file in your home directory.
or to fetch and merge
 
git pull github
 
  
 +
The per repository configuration is stored in the '''.git/config''' file in your repository.
  
Gitk is your friend if you want to visualize all branches and history:
+
=== Colors and Aliases ===
gitk --all
+
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
 +
 
 +
=== 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
  
=== Commit back to svn ===
+
For zsh: http://www.wunjo.org/zsh-git/
See [[Git-svn]]
 

Revision as of 07:07, 10 November 2010

We will switch to git on 19.11.2010, the git repo might be changed/moved/deleted until then, best stick to SVN until then!



How to use git with the papaprazzi-software master repo.

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.

See Git - crash course for an introduction into git 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:

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.

Get the code

If you plan to contribute or just to push your own config to github please first fork the papaprazzi-software repo on github. Just log in and click fork at the top of the main paparazzi-software repo.

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-software.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-software.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-software.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-software.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 merge them run

git pull paparazzi

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

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

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/