Git Overview

Using Git with the FeedHenry Platform

Git

  • An relatively new SCM
  • Great for projects of all sizes
  • Uses "branches" like SVN
  • Each user has entire history locally (fast, plus backups!)
  • Fast, but provides excellent integrity
  • Used for almost all Node.js projects

Common Commands

$ git clone git@tke.fh.com:tke/SomeApp.git
$ git status
$ git checkout [branch-name]
$ git diff [filename]
$ git add ./file/path/*.js
$ git commit -m "Added all project JS files"
$ git push [repo] [branch]
$ git pull [repo] [branch]
$ git reset --hard
$ git blame ./file/path/app.js
$ git tag -a TagName -m "Message"
$ git log

git clone [url]

Clone a project from remote host (FeedHenry)

git status

Get a summary of current local changes

git diff [filename]

View file changes

git checkout [branch]

Switch to an existing branch

git add [files]

Add locally updated files to be commited

git commit -m "info"

Commit changes permanently

git push [repo] [branch]

Push local commits to remote

git pull [repo] [branch]

Pull remote commits and merge with local

git reset [--type]

Remove certain local changes

git log

View commit history

*git blame [filepath]

See when lines were changed and by who!

*Everyone's favourite!

git tag -a [id] -m [msg]

Tag a specific point in time. Useful for releases

Ignoring Files

The .gitignore

The .gitignore

  • Used to specify ignore patterns
  • Git won't track changes on these files 
  • Useful for ignoring binaries
  • Common to ignore generated files
  • Node.js projects always ignore node_modules

Sample .gitignore

node_modules
bower_components
.fhc-debug.log
.npm-debug.log
.DS_Store
.idea

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/

Great!

How do I get started!?

It's easy.

Install Git (Available free online)

Generate an SSH Key Pair

$ ssh-keygen -t rsa

follow the prompts using defaults then...

$ cat ~/.ssh/id_rsa.pub

copy the output from cat to clipboard...

Upload Public Key to Profile

That's it!

FeedHenry Projects

Git Integration

FeedHenry & Git

  • Each App, Service and Cloud App is Git enabled
  • Each has it's own unique Git repository
  • Use this repository to store code for deployment
  • Select a specific branch / tag for use in Studio

Deployed Branch/Tag

Project Git URL

Clone it Locally

Develop

Verify Changes

Commit and Push Changes

Quick Demo

Git Remotes

Using Code External to FH

Git Remotes

  • FeedHenry is a Git remote (stores code)
  • Code is stored in FeedHenry Git 
  • Storing code in your own remote is possible too
  • Adding a second development remote is easy

Adding a Remote Locally

$ cd ~/workspaces/fh
$ git clone [remote-1-url]
$ cd remote-1-url
$ git remote add [remote-2-name] [remote-2-url]
$ git remote -v

A Git Strategy

From FeedHenry PS

Bear in mind;

this is all subjective.

Branches

  • master
  • develop
  • hotfix-<x.y.z>
  • prerelease-<x.y.z>
  • feature-<feature-name>

Master

The latest stable code

Develop

Branched from master dev

Pre Release X.Y.Z

  • "checked out" from develop

  • Used to perform testing

  • Perform final bug fixes

  • Bump the version number

  • Merge back into master and develop

  • Create a new git tag from master once merged

Hotfix X.Y.Z

  • Used to quickly create a patch for production
  • These are "checked out" from master branch
  • Needs to have version bumped once fixed
  • Needs to be merged back into production and master
  • Can be deleted once merged

Rolling Back

Thanks to git tag it's easy

Tag History

Git Overview & Branch Strategy

By Evan Shortiss

Git Overview & Branch Strategy

FeedHenry, and general, Git intro, complete with an example project branching strategy.

  • 1,056