Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

There is a variety of good information about Git available online, including:

Getting Started

Getting help

Most commands have built-in documentation you can access with the --help option:

Code Block
$ git init --help

You can generally access the same documentation as Unix man pages, e.g:

...

Use the git reset command to "undo" an add operation:

Code Block

$ git reset HEAD

This resets the index but leaves your working directory untouched. You can also use git reset to revert to a previous commit; read the documentation for more information.

...

You can also use git diff to see the changes between arbitrary revisions of your project:

  • Changes in working copy vs. previous commit:
    Code Block
    git diff <commit>

-Changes between two previous commits:

...

To resolve the conflict manually:

  • Edit the conflicting files as necessary.

To discard your changes (and accept the remote repository version):

  • run git checkout --theirs README

To override the repository with your changes:

  • run git checkout --ours README

When you complete the above tasks:

  • add the files with git add
  • commit the changes with git commit.

Log, Tags, and Branches

Viewing history

...

Git has explicit support for tagging and branching.

  • git tag manipulates tags
  • git branch and git checkout manipulate branches

Tags

Create a tag:

Code Block
$ git tag [-a] TAGNAME

...

Code Block
$ git checkout master
$ git merge seas-workshop-dev
Updating 1288ed3..33e4a4c
Fast-forward
 version-control.rst |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
git: the index

The Git Index

Git is not really just like Subversion (or most other version control solutions). That's mainly because of the git "index".

  • The index is a staging area between your working copy and your local repository.
  • git add adds files to the index
  • git commit commits files from the index to the repository.

The diff commands uses the index:

  • git diff is the difference between your working copy and the index.
  • git diff HEAD is the difference between your working copy and the local repository.
  • git diff --cached is the difference between the index and the local repository.

Refer back to this illustration if you get confused:

...

Git can integrate with other version control systems.

  • It can act as a Subversion client (may be the only Subversion client you ever need).
  • Can import a CVS repository.

Integrating w/ Subversion

...

This may take a while:

Code Block

$ export CVSHOME=:pserver:anonymous@example.com
$ cvs login
$ git cvsimport -o cvs_head -C my-project

Git Frontends

...