Using git Repositories

This is a very quick guide to using git repositories. It assumes that git is installed and running on your machine. For git information and download, see git homepage . Git is easy to install from source (recommended).

For more detailed information, consult the git man pages, or read the tutorials and howtos on the site given above. Also, run git help -a to see all available git commands.

Quick git Usage

git add .

adds all files in the directory to the git repository

git commit

commits all changes to the git repository

git log

shows the log of commits to the repository

git diff

shows changes between commits, or if outstanding changes have not been committed, shows these changes

git init

creates a git repository in the current directory

git branch

list, create, or delete branches

git status

shows the status of the working tree

git checkout 

switches to a different branch (no branch name defaults to master branch)

Checking out a remote branch, and merging it with a local branch

$ git branch newstuff origin/newstuff
$ git checkout newstuff

Great this new stuff looks pretty interesting, let's merge it back to the local master branch:

$ git checkout master
$ git merge newstuff

Let's push it back to the repo

$ git push origin master

But say we want to push to a different remote branch? First, checkout the remote branch as local, merge the two, push back:

$ git branch dev origin/dev
$ git checkout dev
$ git merge newstuff
$ git push origin dev

-- DuncanPenfoldBrown - 2009-07-23

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | More topic actions...
Topic revision: r2 - 2009-12-04 - patricka
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback