« Previous - Version 28/50 (diff) - Next » - Current version
Squelch, 06/16/2009 21:10
Updated TortoiseGit section to include new version.


GIT

Preface

You will find all the details, screencasts, a link summary and
a git-vs-svn comparison on the Git vs SVN comparison page.

Installation of the Core Applications (MSysGit/putty)

MSysGit is the core application for access to the Git repositories on Dev-heaven. It is is constant development, so please check regularly for updates. We use the SSH (Secure SHell) method of authentication, and Putty is highly recommended to ease access to the server.

MSysGit is required for use with the gui clients.

GitExtensions full installer comes complete with MSysGit so a separate installation is not required, but please use the options outlined below during installation. It also contains Putty. This tool is recommended for those that are new to Git.

  • Install MSysGit (1.6.3 Please look-up the latest available version).
    • It is recommended to add the Windows Explorer Extensions ("Git Gui Here", "Git Bash Here").

Choose Bash and Gui here options

  • Choose to install for Windows Command Line (Middle option, out of 3).

Windows command line option

  • Choose to use PLink for SSH. (browse to your Putty installation folder, or the GitExtensions\putty folder)

Use Plink for authenticating

  • Choose Commit line endings as they are This is important with non text files.

Do not change line endings

Graphical User-Interface Clients

There are several clients available.
You can choose to use one or a combination of them, as you wish.

Git GUI

This is part of the MsysGit Installation.
Usage Help, Examples and Screenshots
The embedded gui is powerful, but lacks some of the extra features that might help new users. Power users

Git Extensions

Usage Help, Examples and Screenshots: A Quickstart Guide
This client has both right click menus and a graphical browser.
The full installer of this client includes MsysGit, Putty and KDiff.
This tool is highly recommended for new users, The setup wizard will create the environment for first time use without needing to use the command line.

TortoiseGit

In Early Beta

This client is basically TortoiseSVN but then for Git, and is very much alike the SVN version.

  • This gui client has matured enough that it is a viable alternative to GitExtensions

Good looking, and more familiar to SVN users. It relies on MSysgit environment being set up correctly, Please download and install MsysGit first

Download the latest version "here";http://code.google.com/p/tortoisegit/downloads/list

JumpStart

Create new repository

  1. Launch git bash
  2. git init
  3. touch .gitignore
  4. git add .
  5. git config branch.master.remote origin
  6. git config branch.master.merge refs/heads/master
  7. git config core.autocrlf false
  8. git commit -m "~ Added: .gitignore."
  9. open .git\config
[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    autocrlf = false
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@git.dev-heaven.net:REPOSITORYNAME.git
    puttykeyfile = t:/PathToPrivateSSHKey/yourPrivateKey.ppk
[branch "master"]
    remote = origin
    merge = refs/heads/master
[push]
    default = current
  1. git push

First Step: Cloning a repository

  • Please make sure your keyAgent (e.g Pageant) is running, and your private key is loaded.
  • Use any application interface or command-line git and clone your first repository:
    git clone git@git.dev-heaven.net:REPOSITORYNAME.git
  • The respective project manager will be able to tell you the repository name.
  • In case of message:
    "The server's host key is not cached in the registry. You have no guarantee that the server is the computer you think it is."
    • Press y(es).
    • In case that doesn't work, first connect once to the host with Putty, and accept the hostkey.

Git basics

  • In Git, you have a local copy of the repository.
  • If you commit, you only commit to your local repository.
    If you want to push your changes to the shared remote repository, you must first git pull, and then git push.
  • If you wish to update from the shared remote repository, you use git pull.
  • If there are things to merge, like changes to files by 2 persons, use git merge.
  • Every git command can be used with --help for basic help output (command-line).

Staging and Committing Changes

Git Extensions

  • Right click a repository and choose Git Extensions -> Browse.
    • You can use this tool to browse the repository + history.
    • You can use the "Commit" option in this tool to stage your changes and commit.
      It works pretty handy with the rescan changes button and other options.

Reverting Uncommitted Changes

Please note:

Any changes you push to a remote repository will be recorded for good in that repository.
This is a feature of Git - All changes are recorded - and cannot be undone.
Please ensure that your local history reflects what you wish to appear on the remote before
you push and edit accordingly.
A revert is still possible but the original mistake will be still be shown on the remote.

Git Extensions

  • Single of set of file revert:
    • Select Browse and then Commit.
    • If your file is already staged, unstage it.
    • Right click the file in the top file list, and choose revert changes.
  • Revert ALL your currently uncommitted changes:
    In the Commit dialog: reset changes hard.

Command-line

  • Single of set of file revert:
    • TODO
  • Revert ALL your currently uncommitted changes:
    git checkout -f

Common git problems

Access denied

Access denied
FATAL ERROR: Server sent disconnect message
type 2 (protocol error):
"Too many authentication failures for git" 

See next item.

Fatal: protocol error: bad line length character

fatal: protocol error: bad line length character

Usually happens when pageant is not running.
Or when you installed MSysGit without pointing it to putty plink.

Note: GitExtensions has a feature to remember and prompt for loading of your private key.

Without telling me which branch you want to merge with.

You asked me to pull without telling me which branch you
want to merge with, and 'branch.master.merge' in
your configuration file does not tell me either.  Please
name which branch you want to merge on the command line and
try again (e.g. 'git pull <repository> <refspec>').
....

Use: git pull origin master
(or push)

Or better setup the mentioned settings (execute from your repository folder):
  • git config branch.master.remote origin
  • git config branch.master.merge refs/heads/master

Push.default value missing

$ git push
warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated.  This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning:   'nothing'  : Do not push anything
warning:   'matching' : Push all matching branches (default)
warning:   'tracking' : Push the current branch to whatever it is tracking
warning:   'current'  : Push the current branch

I get this warning recently after my reinstall with git bash.

They have increased the output from git. GitExt displays it too. GitGUI suppress the warning
You need to specify the branch, or set it in the .gitconfig file.

It should really be local. Each repo may have a slightly different make up.
Tracking or current are the most likely options, but matching is the default,
and for some reason the current branch is not being read

Tracking is for remote and local branches. The local can be named different,
but in fact is a copy of a remote branch. Current is for the branch you are currently on.
Master - for most of the time.

Execute:

git config push.default current

This will create this in the .\.git\config file.

[push]
 default = current

GitExtension Troubleshooting

GitExtensions troubleshooting guide

==========================================================================================================================================

BashnGui.png - Choose Bash and Gui here options (16.9 kB) Squelch, 04/11/2009 00:41

win_com.png - Windows command line option (23.1 kB) Squelch, 04/11/2009 00:41

useplink.png - Use Plink for authenticating (18.3 kB) Squelch, 04/11/2009 00:41

line_end.png - Do not change line endings (23 kB) Squelch, 04/11/2009 00:41

git_extension_preview.jpg (51.5 kB) kju, 04/18/2009 15:14

git_gui_preview.jpg (74.8 kB) kju, 04/18/2009 15:14