Difference between revisions of "Using git and GitHub"

From PioneerWiki
Jump to: navigation, search
m
Line 3: Line 3:
 
== Prerequisites ==
 
== Prerequisites ==
  
A working installation of git, and a github account.
+
A working installation of git, and a GitHub account.
 +
 
 +
The GitHub sign-up page is [https://github.com/signup/free here]. Make a note of your user name as we'll need it to make our initial pioneer repositories.
  
 
If you're on Linux you quite quite likely have git installed already. If you can type <code>git --version</code> at the command line and get a version number back you're good to go. If you don't have it the package repository for your distribution almost certainly will. Use your distribution's package management tools to download and install it.  
 
If you're on Linux you quite quite likely have git installed already. If you can type <code>git --version</code> at the command line and get a version number back you're good to go. If you don't have it the package repository for your distribution almost certainly will. Use your distribution's package management tools to download and install it.  
Line 10: Line 12:
  
 
On Windows you have two options, [http://msysgit.github.com/ Git for Windows] aka msysgit, or [http://windows.github.com/ Github for Windows] which is essentially msysgit but with some extra stuff bundled. Some of which is good ([https://github.com/dahlbyk/posh-git posh git]) and some of which is well, not (github's 'friendly' gui). Since both include the sames command line tools and cross platform gui tools, either is fine for our purposes here. The github one is probably more convenient to install.
 
On Windows you have two options, [http://msysgit.github.com/ Git for Windows] aka msysgit, or [http://windows.github.com/ Github for Windows] which is essentially msysgit but with some extra stuff bundled. Some of which is good ([https://github.com/dahlbyk/posh-git posh git]) and some of which is well, not (github's 'friendly' gui). Since both include the sames command line tools and cross platform gui tools, either is fine for our purposes here. The github one is probably more convenient to install.
 +
 +
== Creating your pioneer repositories ==
 +
 +
== Basic operations ==
 +
 +
git status
 +
 +
git branch
 +
 +
git checkout <branch name>
 +
 +
git branch -a <branch name> ; git checkout <branch_name>
 +
git checkout -b <branch name>
 +
 +
git add -A ; git commit
 +
git commit -a
 +
 +
git push origin <branch name>
 +
 +
gitk
 +
 +
== Updating your branches ==
 +
 +
git fetch <remote>
 +
 +
git merge <branch-name>
 +
 +
git pull --ff-only upstream master
 +
 +
== Making a pull request ==
 +
 +
== Getting other developers code ==
 +
 +
git remote
 +
 +
git remote add <remote> <url>
 +
 +
git remote update
 +
 +
git checkout -b <branch-name> --track <remote>/<remote-branch-name
 +
 +
== Keeping things tidy ==
 +
 +
git branch -d <branch-name>
 +
 +
git branch -D <branch-name>
 +
 +
git push origin :<branch-name>
 +
 +
git clean -n
 +
 +
git clean -f
 +
 +
== Reviewing a pull request ==

Revision as of 15:05, 2 December 2012

Developing on pioneer means using the version control tool 'git' and the github website. git especially has a reputation for having a steep learning curve, so here we'll try to give you enough knowledge to be dangerous!

Prerequisites

A working installation of git, and a GitHub account.

The GitHub sign-up page is here. Make a note of your user name as we'll need it to make our initial pioneer repositories.

If you're on Linux you quite quite likely have git installed already. If you can type git --version at the command line and get a version number back you're good to go. If you don't have it the package repository for your distribution almost certainly will. Use your distribution's package management tools to download and install it.

If you're the type of Linux user who builds everything from source, rolling your own kernels, I'm going to assume you're already quite familiar with git, and this was not the page you were looking for :)

On Windows you have two options, Git for Windows aka msysgit, or Github for Windows which is essentially msysgit but with some extra stuff bundled. Some of which is good (posh git) and some of which is well, not (github's 'friendly' gui). Since both include the sames command line tools and cross platform gui tools, either is fine for our purposes here. The github one is probably more convenient to install.

Creating your pioneer repositories

Basic operations

git status
git branch
git checkout <branch name>
git branch -a <branch name> ; git checkout <branch_name>
git checkout -b <branch name>
git add -A ; git commit
git commit -a
git push origin <branch name>
gitk

Updating your branches

git fetch <remote>
git merge <branch-name>
git pull --ff-only upstream master

Making a pull request

Getting other developers code

git remote
git remote add <remote> <url>
git remote update
git checkout -b <branch-name> --track <remote>/<remote-branch-name

Keeping things tidy

git branch -d <branch-name>
git branch -D <branch-name>
git push origin :<branch-name>
git clean -n
git clean -f

Reviewing a pull request