Difference between revisions of "Git"

From PaparazziUAV
Jump to: navigation, search
Line 72: Line 72:
 
Gitk is your friend if you want to visualize all branches and history:
 
Gitk is your friend if you want to visualize all branches and history:
 
  gitk --all
 
  gitk --all
 +
 +
=== Commit back to svn ===
 +
See [[Git-svn]]

Revision as of 14:42, 22 October 2010

How to use git to commit to the paparazzi git repository.

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.

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 mayo lead to a lot of extra headscratching among migraters. You have been warned.

Configuring 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.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

If you want some github awesomeness you have to set up an account there and set your github token.

Get the code

Clone from Github

If you want to push to your own repository on github please first fork the main paparazzi repo there. Then clone from your repo on github:

git clone -o <username> git@github.com:<your github username>/paparazzi3.git

Otherwise clone directly from the master repo (read-only):

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:

git clone -o github git@github.com:paparazzi/paparazzi3.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.

Adding remotes

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:

git remote add github git://github.com/paparazzi/paparazzi3.git

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

To get the changes from the master branch on github run

git fetch github

or to fetch and merge

git pull github


Gitk is your friend if you want to visualize all branches and history:

gitk --all

Commit back to svn

See Git-svn