Talend Subscription Solutions support different flavors of Git including GitHub, Gitblit, and BitBucket. This post will cover general concepts of versioning, branching, and best practices.
With Git, a branch will always begin as a copy and will move forward from that point in time, creating its own history. A Talend project can be associated to its own repository or a particular branch/tag. If a repository is associated with multiple Talend projects, then any branches or tags within that repository will be visible across those Talend projects. After a Git repository has been configured and verifying that the repository is accessible for pushes, a branch can be created to begin development.
Generally, development teams will define their own workflows. With Git projects, branches will either be remote by default or local. A local branch means that the developer is working offline in the branch that was last worked on. Changes are committed to the local repository only and need to be pushed to a remote branch before merging back to master.
The examples below will use a remote Git repository and provide scenarios with developers Jane Smith and Tom Baker.
In the first example below, Jane will clone a branch from master, create a job, then merge back to master.
There are two approaches to create a branch; checkout as a local branch or New Branch.
check out as a local branch
After the new branch has been created, the repository will now show (Local Mode) indicating any development will be local. In addition, the local branch will appear in the repository menu.
An indicator (
* [ 6 ]) shows how many changes the local branch is ahead of master. The initial cloning of a branch will write metadata in the form of several commits. At this point, the local branch could be pushed to master. As an example, a job will first be created in the local branch.
Once the job has been created, changes can be pushed to master.
In the following example, Tom has developed a second job and has not pushed changes.
If Tom attempts to switch to the remote branch (which in this example is master) with uncommitted changes on the local branch, the Studio will display an error:
After Tom pushes changes to master, Jane will pick up development on the second job in the next example.
Jane has returned to the Studio and switches to the local master branch. The studio will automatically pull from master:
A manual pull and merge can also be done through the repository menu:
Once the repository has been synced, Jane continues work on the second job. At the same time, Tom also continues work on the second job and commits his changes.
Note: both Jane and Tom are working in local mode; if the repository was in remote mode, the item would display as locked and only a single user would be able to access the item at a time.
Jane attempts to commit:
If there are conflicts found, the following message will appear:
In order to resolve the conflicts, the Git Merge perspective will display a Conflict Navigator:
The items in conflict will appear in the tree structure. After selecting the conflict item (job2), a detailed comparison of the conflicts will be displayed. Additionally, by selecting specific components or connections in the item, they will become highlighted in the view.
Conflicts can be resolved a the component/connection level, or at the item level.
Component/Connection Level Resolution
Item Level Resolution
After the conflicts have been resolved, a dialog box will be displayed to continue the commit process:
Copying Between Branches
Jobs can be copied between branches directly through the repository:
To perform a comparison of versions, right click on the job and select Compare Job:
After selecting the desired versions, the studio will display the compared jobs side-by-side as well as with a tree structure:
Each time a job is saved or run, a commit occurs. Each commit will automatically add user information. In the repository menu, choose More… and Show History.
History can be viewed directly from the studio:
By clicking on a commit, detailed information will be displayed:
Author: Administrator <Administrator@localhost> 2016-12-21 21:06:33
Committer: Administrator <Administrator@localhost> 2016-12-21 21:06:33
Parent: 026bb08e7c5186fa7dd80a79454eb3bc33c72422 (User 'firstname.lastname@example.org' at 21:04:28 CST 2016-12-21 : )
Parent: 7cb5ff139078384b7f492c04272aa9e287dd5868 (User 'email@example.com' at 21:06:09 CST 2016-12-21 : User action : Delete forever Save project 'Project')
Child: e2fe51756cf0e351def21f8a7463269189bbbf04 (User 'firstname.lastname@example.org' at 21:06:40 CST 2016-12-21 : User action : Delete Delete (logical) process item 'job3' at path '' in project 'Project' Save project 'Project')
Branches: master, origin/master
Merge branch 'master' of http://admin@localhost:8558/r/project.git
The best practices for Git are outlined in the Talend Software Development Life Cycle documentation.
The complete documentation for working with project branches and tags with Git is available in the documentation.