Git

Committing Changes

Commits should, as much as possible, contain changes that relate to a specific feature or ticket. This is to allow them to be reversed later if needed.

The commit message should describe what has changed. If the change relates to a JIRA ticket it should be prefixed with the ticket identifier. This will then create links in Jira/BitBucket (note that this doesn't work if you are working cross instances - for example using the N3 Jira and Internet Bitbucket).

git commit -m "RR-123 I changed function val_banana to add a check for apples"

Moving Committed (but not Pushed) Changes to another branch

This is useful when you try to Push changes to Services to Master and it gets rejected with a message that you need to do this via a pull request.

Run:

  • git fetch origin

  • git rebase origin/master

  • git reset --hard origin/master (Check before doing this that git status is clear)

See https://stackoverflow.com/questions/5066041/moving-committed-but-not-pushed-changes-to-a-new-branch-after-pull

Useful reference Articles/Sites

Dangit, Git!?! How to sort errors when committing