Committing code

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.