Pages - Menu

Getting Started with Git 101


I have used many SCM in the past. VSS, SVN, TFS, ClearCase, Mercurial etc... There are so many of them yet they are so similar, so that they are not even worthy for a spot in a resume.

However, git was a little more challenging to me as their structures and architectures are different. I have now used git for just over a year now, and put the followings together that covered what I believe is a good starting point to learn git commands.



I use posh-git and found the default dark red color was a bit hard to read against a dark background color in Windows console. I changed them to yellow and magenta by updating the ~/.git/config.

    ui = true 
[color "status"]
    changed = magenta bold
    untracked = yellow bold


# Change a global setting
$ git config --global --edit

# Change editor to notepad globally
$ git config --global core.editor notepad

# Setup git diff / merge tool globally
# for example, if we are using p4merge as a diff / merge tool.
$ git config --global diff.tool p4merge
$ git config --global merge.tool p4merge

# Git merge generates unwanted .orig file
$ git config --global mergetool.keepBackup false

Basic Changes

# Check pending check-in status
$ git status

# Get latest files
$ git pull

# Change branch
$ git checkout <branchName>

# Add files for pending check in
$ git add <filename>

# Undo a git add
$ git reset <filename>

# Delete files for pending check in
$ git rm <filename>

# Undo pending delete files 
$ git reset head <filename>

# Amend last commit
$ git commit --amend

# Undo commit
# This will reset the the branch to a previous commit 
$ git reset HEAD~

# Hard reset is a potentially dangerous command
# Changes are destructive and may not be recovered
$ git reset --hard <commit-id>

# a force push will force the origin to point to the same commit as local
$ git push origin HEAD --force

# Discard changes in working directory
$ git checkout <filename>

# Discard untracked files in working directory
# Double check what to delete
$ git clean -f -n

# The actual deleting
$ git clean -f 

# Discard untracked folders in working directory
$ git clean -df 


It is similar to shelve in TFS.

# All unstaged and staged dirty files will be "stashed", 
# and the working directory will be cleaned.
$ git stash

# shows the list of stash
$ git stash list

# shows content of stash
$ git stash show -p

# retrieve then remove changes from the stash 
$ git stash pop

# apply changes (and not removing) from the stash
$ git stash apply

# remove changes from the stash
$ git stash drop

# remove all stash history
$ git stash clear


# Delete a local branch
$ git branch -d <branchName>

# Delete a remote branch
$ git push origin :<branchName>

# Rename current branch
$ git branch -m <newname>


# Merge a branch from source to destination
$ git checkout destination-branch
$ git merge source-branch

# Resolve a merge conflict
$ git mergetool

# Resolve merge conflict with theirs or ours preference during a conflicted state.
# Take their changes
$ git checkout --theirs *
$ git add *

# Take our changes
$ git checkout --ours *
$ git add *


# listing tags
$ git tag
# add tag
$ git tag -a <tagName> -m "A message for tagging"
# push local tags to remote
$ git push origin --tags

# branch out from a tag
$ git checkout -b <newBranchName> <fromTag>


# Rebase branch from parent branch
$ git rebase <parentBranch>

# Conflict during rebase
$ git rebase --[abort|skip|continue]

Fork and Submodule

# Add a remote repo to current repo as a subfolder
$ git submodule add <gitRepo>
# Get latest in submodule
$ git submodule update

Demandware - Bazaarvoice Cartridge Decoupling by Using Tealium and Commerce Connect


We are implementing a Bazaarvoice integration with our Demandware ecommerce platform. For general Demandware customers, that require installing and configuring the Demandware Bazaarvoice Cartridge from the Demandware Marketplace.

For us, we are slightly ahead in our game plan and we can do something a bit more advance. We use Tealium for our tag managment and Commerce Connect for our feed integration. Therefore, we can put our Bazaarvoice beacons in Tealium, and our product feed from Commerce Connect. Then our Demandware implementation became a simpler implementation with just the review containers and the submission isml template.


In a nutshell, we are implementing a bunch of Bazaarvoice products and we distributed some of the responsibilities to other products depending on what is required.

The general idea of the above is to leave the html changes in Demandware, put all javascripts in Tealium, and create feed jobs that run from CommerceConnect.

SEO is implemented within the Demandware cartridge.

Product Catalog Feed is moved to Commerce Connect - The same platform that we use to manage our eBay or Google feed. We can setup a new channel with the Bazaarvoice type.

Question and Answer / Ratings and Review are split into both Demandware and Tealium. The bvapi.js tag will go to Tealium, but we need to implement the html containers or initialize the inline ratings in Demandware.

ROI Beacon is basically a javascript call to do $BV.SI.trackTransactionPageView(). This is achieved via Tealium.

For Submission form, this is a piece of stand alone Bazaarvoice component for customer to submit reviews, so I leave everything in Demandware including the javascript. It is implemented in the Demandware cartridge as Bazaarvoice-Container pipeline.

We also made some UI changes to include our company header in the container. Container URL is done via Config Hub.


There were a few hurdles during this process, but as our ecommerce system grow and integrate with many vendors, it is essential to setup all this foundation correctly.

By decoupling some of the job responsibilities to other vendors, our ecommerce system can focus on strategy and planning, while leveraging our vendors to help us managing our tags, product feeds or product reviews.