Working with Git

This guide explains how to set up a local OSEE source repository using Git. When you complete it, you will have an Eclipse workspace populated with the OSEE projects from your Git working directory, with full tool support from both the EGit plugin and the original command-line git.

Change Windows HOME setting if mapped to Network

By default, in Windows, git sets the HOME environment variable used by its bash to whatever the HOMEDRIVE variable is set to.
When the HOMEDRIVE is mapped to a network drive, this introduces an annoying delay before git commands execute.

To change the HOME directory setting, perform the following steps:

Copy the following files from your mapped HOMEDRIVE to the directory where you'd like your real HOME directory to be; for this example "C:\UserData\git" will be used.

Create a "HOME" variable in Windows that points to your desired directory:

Right-Click on MyComputer (Desktop or Start menu) and select Properties.

Click the Advanced tab and then the Environment Variables button at the bottom.

In the "User variables" area click New.

Enter the following without the quotes.

Variable name: "HOME"

Variable value: <path to directory as seen by git bash>; e.g. "/c/UserData/git"

Click OK twice to save the changes and close out the System Properties window.

Restart your git bash session.

Change default drive on GIT Bash Startup

After a git bash restart, you will notice that the prompt defaults to the Windows HOMEDRIVE instead of the new home directory "~".
This is due to cmd.exe using the Windows HOMEDRIVE location.
To get around this, do the following:

Create a ".bashrc" file in your new HOME directory and put "cd ~" on the first line.

Additional Windows Settings

Change the size of the cmd window:

To start drag the bottom of the window to a desired height.

Next, Right-Click on the title bar and select Properties

Click the Layout tab and change the "Screen Buffer Size" to something like 160 Width and 1000 Height; increase the "Window Size" Width to match your buffer size (the Height was set when you dragged the window bigger).

OSEE Git Development Workflow

Code conflicts and integration problems should be discovered as soon as possible

Fix small problems often instead of fixing large problems seldom

Always releasable

Keep it simple and repeatable

The OSEE Git repository contains the following main branches:

master:origin/master is the main branch where HEAD always reflects a production ready state.

build_dev:origin/build_dev is the main branch where HEAD always reflects a state with the latest delivered development changes for integration.

build_int:origina/build_int is the main branch where HEAD always reflects a state with the latest changes from development that have been tested/built and ready for customer assurance testing. The integration branch reflects the last development changes that have been incorporated into a release candidate.

Developers wanting to incorporate a change for a specific build should make the change in that build's development branch (ex. 0.9.6_dev).

☞ Developers should not make changes on master or _int branches

Setup

Create a directory for the git repository (example: c:\gitroot)

cd into the local git directory

Create a clone of the OSEE repository: git clone https://<commiterId>@git.eclipse.org/gitroot/osee/org.eclipse.osee.git

cd into org.eclipse.osee folder (the local OSEE repository)

Add credential information:

git config user.email my_committer_email@address.com

git config user.name "committerId"

Local Development

☞ Development should only be performed on a development branch (never commit to master, or *_int branches)

Track a development branch

Before starting development, we need to create a local tracking development branch.
You only need to perform this step at the beginning of the development cycle.

Merge branch into current branch, if there is nothing to merge a fast-forward will be performed. HEAD pointer moved to HEAD of branch

git merge branch

Branching and Merging

To replace with incoming file so you can re-make your changes (or abandon them)

git checkout --[theirs|our] <path>

Continue rebasing

After conflicts have been resolved

git rebase --continue

Patches

Generating individual patches (one per commit) to submit by email (or bug report), exports all commits made to current branch, from trunk to HEAD "-o ../" puts them one level above in individual .patch files

git format-patch -o ../ trunk..HEAD

Local Change Patch

Generate a big patch for your local changes, (good for backup), In this case Z:\ is mounted as a shared windows folder, so if you do not have faith in your local backup software, this could help you quickly restore your work.

git diff trunk HEAD -p > Z:/backup_date_time.patch

Splitting commits

In case you have multiple, conceptually unrelated changes in a single commit you can split them by doing an interactive rebase

--Rebase current working tree
git rebase -i HASH_WHERE_TO_START_FROM
-- mark 'e' or 'edit' the commit you want to Edit/Split.
-- When you get dropped back into the shell, issue:
git reset HEAD^
--which effectively undoes that
-- commit and leaves the modified files unstaged ProGit Book Chapter 6-4
-- Afterwards you can 'add' and 'commit' changes as appr.
--To resume rebase operation issue:
git rebase --continue

Change author name/email of a commit with yours

Edit commit author, email, or comments using the following. This should only be performed on commits that have not been pushed to the remote repository. If you just need to change the author name you can change --reset-author with --author AUTHOR NAME