Git

Setup/Configuration

sudo aptitude install

git-core git-gui

Name, eMail, Highlighting

git config --global user.name <name>
git config --global user.email <email>
git config --global color.ui "auto"

Trailing whitespace error during commit

Quick & Dirty Workaround:

chmod a-x .git/hooks/pre-commit

Not as Quick but still dirty: Comment out following lines, so they are ignored/not processed

if (/\s$/) {
  bad_line("trailing whitespace", $_);
}

Fixing strange error when pushing

/> git push <remote_name> <branch>
Counting objects: 14, done.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (13/13), 283.77 KiB, done.
Total 13 (delta 2), reused 0 (delta 0)
*** Project description file hasn't been set
error: hooks/update exited with error code 1
error: hook declined to update refs/heads/master
To ssh://login@host/path/to/repo
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'ssh://login@host/path/to/repo'

chmod -x .git/hooks/update

Working

Setup Repository

  • git --bare init'' (just repository (no project file) is stored)
  • Clone existing repository
    git clone ssh://<user>@<host>:<port>/path/to/repo /path/to/localfolder

Setup Remote Repository on localhost

  • git remote add <remote_repo_name> ssh://<user>@<host>/path/to/repo
  • Initial push:
    git push <remote_repo_name> <branch>

Working with remote repositories

General Workflow:

  1. Get remote changes and merge into local repository:
    git pull <remote_repo_name> <branch>
  2. Publish local changes to remote repository:
    git push <remote_repo_name> <branch>

    or, when working with branches:

    git push <remote_repo_name> <local_branch>:<remote_branch>

Commits

  1. git add .
  2. git commit -a -m "Commit Message"

Working with branches

  1. Show available branches:
    git branch
  2. Create new branch from current HEAD:
    git branch <newbranch>
  3. Switch to new branch:
    git checkout <newbranch>
  4. Work, commit on <newbranch>
  5. Switch to master (or other branch):
    git checkout master
  6. Merge changes from <newbranch> into current branch:
    git merge --no-ff <newbranch>
  7. Delete <newbranch>:
    git branch -d <newbranch>
git.txt · Last modified: 2010/07/01 16:38 (external edit)
CC Attribution-Noncommercial-Share Alike 3.0 Unported chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0