From SLangTNG


Git basic usage

Before starting

Before starting you should configure git:

git config --global "Your Name Comes Here"
git config --global

Furthermore, it would be nice to have colored output (if you like it):

git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto

The configuration will be stored in ~/.gitconfig

Git server at

There exists a How-To which describes usage of the Git configuration at Tuxfamily. Projectname slangtng and Git repo is slangtng.

Print status and history

A brief summary is given by

git status 

The history of own changes is obtained by

git log 

Complete diffs:

git log -p 

Overview of the change of each step:

git log --stat --summary 

Fetching changes from the master repo

The equivalent of cvs update which merges in any work that others might have done since the clone operation is:

git pull origin 

If there are uncommitted changes in your working tree, commit them first before running git pull!!

The pull command knows where to get updates from because of certain configuration variables that were set by the first git-clone command.

Submitting changes to the master repo

You can update the shared repository with your changes by first committing your changes (see section "editing"), and then using the git-push command:

git push origin master 

As long as the shared repository does not have any branches other than master, the parameter "master" can be neglected (else ALL other branches will be pushed/pulled as well)

Modifying and committing files

Add the updated contents of some files (new or modified files) to the index:

git add file1 file2 

You can see the planned changes by

git diff --cached 

You can see all changes (which may not be part of the index) by

git diff 

Commit all changes which have been passed to the index:

git commit 

Commit and adding ALL tracked changes to the index in one flow (but without adding new files):

git commit -a 

All changes being committed are merged into the local repository in the users' working directory. At times he should synchronize his clone with the main repository using the push and pull commands.

A notice on log messages: 1st line: max. 50 characters - short description. the other lines: long description. You can also pass log messages as command line paremeter via git commit -m "message"

Undoing a change

If you have changed a file by accident you can restore it from the master repo:

rm filename
git checkout filename

Unexpected behaviour

Push fails

Beginners often have the error message "rejected" when they want to pull or push changes from/to the master repo. This is the case when Git found modifications in the working directory which were not yet committed (Git ignores new files as long as they were not added to the index). Those changes must be committed to the index or into a separate branch first. After that push/pull should work fine. Git will automatically merge all changes from the master repo into the users local branches. If conflicts appear they are made visible by modifiying local files which in turn must be resolved by the user and committed to the index.


Information for users
Personal tools