Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

By giving a branch, tag, or commit number in git checkout <commit> <path>, you can get to any existing version of the files. If no path is given, git checkout <commit> switches your whole working copy and index to the specified branch, tag, or commit number. If If git reset is given a commit number, the current branch is modified to point at the given commit.

...

In case the working directory is messed up with unstaged files, which are not affected by git reset --hard, a clean up is achieved by means of git clean -f. The additional switch switch -d applies this to directories, respectively. Hence, git reset + followed by git clean act like svn revert.

git clean -X removes only the files that are ignored by Git, that is mainly the .class files generated by the Java compiler. A full rebuild is required afterwards.

Branching and Merging

...

Branches are used to structure your development and are an essential tool for effective work in the KIELER team. Read the Source Code Management page if you haven't yet understood what branches are good for.

Creating a Branch

Do one of the following:

  • Right-click the KIELER repository in the Git Repositories view, click Switch To, click New Branch.
  • On the command line, enter git branch <name>. In this case, the new branch is not active; if you want to activate the new branch while creating it, enter git checkout -b <name>.

In either case the new branch starts at the current position of your working copy, i.e. it branches from the current branch you are on. In order to branch from a different position, either check out that other branch first or select it as source ref in the EGit wizard (on the command line simply type git branch <name> <start_point>).

Switching to Another Branch

Do one of the following:

  • Navigate to the branch in the KIELER repository in the Git Repositories view, right click it, click Checkout.
  • On the command-line, enter git checkout <name>.

Note that your local uncommitted changes are transferred when switching the current branch.

Merging Branches

You always merge another branch into the current branch. Therefore you first have to checkout the target branch prior to merging. Then, do one of the following:

  • Navigate to the source branch in the Git Repositories view, right-click it, click Merge.
  • On the command line, enter git merge <source_name>.

This creates a new merge commit, i.e. a commit with two source commits, and the target branch (the one you're currently on) contains all changes that have been done in the source branch (the one selected for merge). The source branch is not modified. A merge is done implicitly when pulling: assuming you're on branch master, the command git pull origin master is the same as git fetch origin followed by git merge origin/master, where origin/master is the remote tracking branch for master.

Working With Multiple Remote Repositories

Gitorious allows the creation of personal server-side clones of the KIELER repository, which is highly encouraged as described on the Source Code Management page. When working with such clones, it is often necessary to synchronize the different server-side repositories with the local one. Git supports this by allowing to configure multiple remotes in the local repository. On the command line this is done simply by entering git remote add <name> <url>, where <name> is an arbitrary local identifier for the remote repository. For example, a remote named origin is automatically created when a local repository clone is created through git clone <url>.

When you push or pull branches, simply select the remote you wish to interfere with. Pulling is done by git pull <remote> <branch>, and pushing is done by git push <remote> <branch>.