Der Header: Enauts Thinking!
created:Sat 15 Feb 2014
edited:Fri 30 Oct 2015

Git – a small user guide

Git is a nice tool to manage ones source code as well as tons of other files. There are hundrets of git howtos already out there but this one is mine. I just setup my git as I'm used to it.

Installation

The installation with fedora:

$ sudo yum install git gitg git-svn

Setup

My favorite setup is basically the default. With added colors and of course setting the email and name:

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
$ git config --global color.ui true

Basic Git workflow

Checking out in git is rather cloning the whole repository:

$ git clone git@server.domain:git-repos

Once checked out the following three actions are most important:

  1. modify files
  2. commit files
  3. push to server

Modifying the files in the repository untill some atomic commit is ready. Once a commit is ready the next commit is prepared. This is a little different from other version controll systems but it is very effective. To create a commit the changes that should be in that commit have to be added to the so called staging area. This is done by:

# to add a file as a whole
$ git add filename
# to get an interactive change adding mode that
# iterates though the changes made
$ git add --patch

Once the changes that will be in the next commit are staged recheck this with:

$ git status  #display the status of the repository

Committing the changes is then done with:

$ git commit

Write a meaningfull commit message into the repository so that everybody understands what you changed. Then save and quit the editor.

The next stepp pushes the locally committed changes to the remote server do so by:

$ git push

If the server complains that you do not have the most recent version update your local git repository. It is wise to allways update right before one starts to work on the repositories to avoid unnessesarry conflicts. Do so with:

$ git pull

Git-SVN workflow

Unfortunately svn is still widely used but with git-svn a lot of its trouble can be eased. There are some of the most important commands:

#checkout a files and history to a git repository.
$ git svn clone svn://server.domain/repository-path
# for updating if there is a new version in the remote repository.
$ git svn rebase
# to send the local commits to the server.
$ git svn dcommit

Comments

Add a new comment

Note that all comments are moderated - so your post will not appear till I find time to accept it.

The comments do use markup syntax.

Name:
Email:
Confirm Email: leave the above line empty!
Comment: