Working with Tickets and Branches

Any work being done must have a JIRA ticket associated with it.

In order to make the pull requests more manageable, please keep the tickets reasonable small.

Once you have made some code changes, you'll want to commit and push them so that they are backed up. A commit can be thought of like a "package" that takes a bunch of changes you've made and wraps them up together with a message explaining the changes. The commit message should start with a JIRA ticket number, like "IKP-291 <description of changes>". You can commit code using the GIT CLI or any other GIT client (e.g., SourceTree). Here's how to do it with Sourcetree.

 

 

  1. Check out your branch.
    In this example, the branch is 'IKP-2143-chkp-hardware-status-missin' (in bold in the UI).
    Start on the 'File Status' tab.

 

2. Make some changes to the code.
Here I've made a dummy change to 'show-sysenv.ind'.You can see that it ia 'unstaged'

 

3. Stage the files you want to commit.

In GIT, there are three phases:

  • unstaged

  • staged

  • committed

     

4. Commit your work.

Once you've staged, you are ready to commit.Please create a meaningful commit message that other developers would find informative.

 

5. Review your committed work.

Once you've committed, if you want to see your commit, go to the 'Log/History' tab.

To make the history easier to understand, filter by 'Current Branch'.

Observe the just created commit.Also note the '1 up arrow' icon. This means: "you are 1 commit ahead of the remote branch. You need to push to sync the remote with your commit”

When you create a new branch based on another branch, after you've made a commit, here's a model of what the branch commits look like (c = commit, the numbers are arbitrary). I.e., you have all of the commits from staging, plus your new commit.

staging c1 --- c2 --- c3 <--- other commits in the parent branch just before you branched \ \ your IKP dev branch c4 <--- your recent commit, after you've branched and created a new commit.

Once the code is committed, you can make more changes and more commits, but at some point, you will sync your work up to the remote repository. To do this, you 'push' the commits. In Sourcetree, you do this:

  1. Click the 'Push' button.

 

2. Make sure you are only pushing from - to the branch you want.

 

3. View the code in the remote repository.

 

When your code is done - meaning you conducted thorough testing on a real device, it is time for the pull request.
For more details about pull requests requirements, see Code Review / Pull Requests
To create a pull request. you use Bitbucket.
Your pull request should be from the branch you're currently working on and into staging. Here's how to do this in Sourcetree:

  1. Go to your IKP in JIRA, and click on the 'branches' link.
    In the popup, click on your branch. Usually, there is only one to choose from.

 

2. On the branch page, select the 'Create pull request'.

 

3. Finally, create the PR. Make sure to target the correct destination branch, add a reviewer, and always select 'Close <branch_name> after the pull request is merged'.

 

Once the pull request is approved, someone else will do the final "merge" into staging.
The code will then be tested automatically.

Bam, you're code has made it to the world.

Switching Between Branches (aka 'git checkout')

Sometimes you will need to work on multiple branches at a time. This might seem a bit scary because it might seem like the code for the different branches might affect each other. But don't you worry, git will keep track of this for you. It will automatically update your local files to reflect that of the branch you're switching to (checking out).

All the changes you've made to the previous branch might seem to disappear, but changing back to the previous branch brings them back again. This makes it super easy to work with multiple branches. The only thing to keep in mind is: whenever your writing any code, just make sure you're on the right branch (i.e., the branch related to the changes you're making).

What are GIT, GitHub, Sourcetree, and Bitbucket?

First: git and GitHub are not the same thing: git is client-side (a local executable), and GitHub is server-side. You can use git to manage your local code source and "push" updates to the remote GitHub server.

There are many different clients and servers in the "git ecosystem". git is a command-line client. There are many other clients, esp. GUI clients that use git under the hood. Sourcetree is a client that many indeni developers use. In terms of servers, GitHub is the most well-known git server, but indeni doesn't use GitHub, it uses a server called Bitbucket. You can use any git client to interact with Bitbucket. Broadly speaking, Bitbucket is the 'same thing' as GitHub. But, Bitbucket and Sourcetree are Atlassian products, and so they have some very helpful integration with other Atlassian products, most importantly Jira. You'll see how some of this integration works below.

How to apply a commit from other branch to your current branch?

This action is called cherry-pick, this should be use only as remediation in specific cases. Useful when a branch is closed and you want to apply only changes made into that closed branch to other where you’re working.

https://www.atlassian.com/git/tutorials/cherry-pick