From cTuning.org

Jump to: navigation, search
Navigation: cTuning.org > CTools > ICI

Gentle introductions to Git

There are several nice tutorials for users new to Git - please have a look at Git documentation page and choose the material best matching your needs and your level of acquaintance with Git.

For power users of SVN, the SVN Crash Course will be a great help in the migration to Git.

Branching

The idea behind the implementation of branching in GIT is to make experimentation easy without sacrificing proper version control. As a result, branching in GIT is a simple and fairly lightweight action, because branches are simply new series of content changes. Creating a branch does not require the creation of a copy of the forked-off source, and can be done in the current working repository.

N.B.: while time and space requirements for creating a new branch are low, the time needed to switch to (check out) an existing branch depends directly on the size of the source tree. Typically, creating a new branch takes only a few seconds (5s for a full GCC tree), while switching to significantly different branch of the GCC tree takes one to two orders of magnitude more depending on the amount of differences.

To see which branches are available in the current repository, simply invoke git-branch: it will list the branches, with the active branch preceded by an asterisk:

$ git-branch
  ici-patch-testing
* master
$

Switching between branches is done by checking out the desired branch:

$ git-branch
  ici-patch-testing
* master
$ git-checkout ici-patch-testing
Checking out files: 100% (7612/7612), done.
Switched to branch "ici-patch-testing"
$ git-branch
* ici-patch-testing
  master
$ 

Creating a branch is done by calling git-branch with the name of the new branch as argument (if the branch already exists, GIT will tell you so):

$ git-branch master
fatal: A branch named 'master' already exists.
$ git-branch plugin-mgmt
Switched to branch "plugin-mgmt"
$ git-branch
  ici-patch-testing
  master
* plugin-mgmt
$

By default, the branch is created off the current state of the local tree. This can be changed by using the '-r' ('remote') option and/or by specifying a specific start point - see 'git help branch' for details...

Tracking: it is possible to set the new branch to automatically track the changes applied to the original ("parent") branch by specifying the '--track' option when creating the branch using git-branch, or by setting the GIT configuration variable branch.autosetupmerge to true.

TODO: Merging. Merging of branches is greatly simplified by the power of GIT pull and push actions. By pulling change sets s from a specific branch, these changes are merged into the current local branch. Afterwards, locally committed changes can be pushed onto the remote repository to update the remote location. And there is the git-merge command, which needs a separate discussion.

Locations of visitors to this page