UIMA project logo
Git notes
Apache UIMA

Search the site

 Configuring some aspects of Git Repo

You may create a special file in a branch, at the top level, named .asf.yaml which controls some automation at Apache.

For some settings, this file must be in the "master" branch.

See this page for details.

 Frequently used git actions

Working with two branches in one repo

It may be best to have two separate local directories, each with a separate clone. because if you just have one clone and switch between branches, the switch operation the working tree might have "extra files" from the other branch, which you'll need to be careful to ignore. In Eclipse these extra folders will look like they're waiting to be added.

To clone and then check-out a non-default branch, use

git clone https://... -b branch-name

Alternative: Have one clone, switch between branches

For example, if you have both master, and master-v2 (as is the case for core uima).

Goal / Task Git command Comments
Switch between branches

git status (to confirm things are clean)

git checkout <branch-name>

The checkout switches to the other branch. Before you do this, please insure the working tree has no local modifications. Otherwise the checkout command will complain.

The checkout operation may not remove directories or files that are present in one branch but not in the other. Don't remove these (Eclipse gets confused if you remove them); just don't stage them or otherwise change them.

Create new branches for bug-fixing or features see below, but do for each version This is if you are independently committing changes to each branch

Common situations

Goal / Task Git command Comments
Creating a new branch for a feature or Jira issue

git clone https:... -b master-v2

git checkout -t -b new-branch-name

git push -u origin new-branch-name

OR

create the branch on the github.com website, from the desired master (e.g. use

the github pulldowns to switch the branch first to the one to branch from, e.g. "master-v2").

git checkout -b new-branch-name

(no push is needed, the remote already has the new branch)

The first operation sets the base from which you will branch. If no -b branch-name is specified, the default branch is used (typically master).

The checkout with -b will create a new branch and switch to it. The -t will sets up the configuration so that git pull (with no arguments) will pull from the starting branch (in this example, the local master-v2).

The push will update the remote with the new branch. The -u operation creates the remote tracking branch, so that git push will go to the corresponding new remote for this new branch.

Undo some commits

git log --oneline

git reset --hard the-hash-or-ref

or

git revert the-hash-or-ref

The log command shows you the hashes for the commits, so you can find the last one you want preserved.

The reset should only be used if this is a local commit and hasn't been pushed.

The revert applies the changes needed to revert. Use it when the commit has been pushed to some public spot.

If the remote as been updated, use "revert" and push the change to the remote.