I went today to a Git/GitHub training organized by Canoo and lead by Tim Berglund ( The online training presentation is available at use first left key then left/right/up and bottom keys to navigate through the slides.

My notes are still under reviews, but are available at

GitHub also offers free, short, topical online classes about GitHub, Git and the union of these two technologies Here.

GIT training

  • Tim Berglund
  • config
    • global
      • user level config for logged in user
    • local
      • use when pushing to github later
    • system
      • apply to every user logged in on the machine
    • Git autodetect file type
      • binary
      • text
        • CRLF

          • dont mess with it if it is working

          Colorize console output for legibility
          git config --global color.ui auto

          Force files to be LF in the repo, even on Mac/Linux
          git config --global core.autocrlf input

          Force Windows to convert to CRLF
          # on checkout and to LF on `add`
          git config --global core.autocrlf true

    • Git Help
      • git help config
        • To print and read
  • 1. Staging area
    • first add
      • git init newproject
      • cd newproject
      • vi caesar.txt
      • git status
        • file red
          • untracked
          • modified
      • git add caesar.txt
        • file green = tracked
        • it is now in staging
      • refs are name for objects
        • ex master
      • modifiy the file
        • vi caesar.txt
      • file has to go to staging before being committed
        • git add caesar.txt
          • go in staging
          • when in staging the file has no refs
        • git commit -m "small change"
          • now has a name associated to it
    • Why
      • so you can work on paralell files or topics
        • is it not a bad sign?
      • you can also commit then later "part" of the file
        • you could break easily since unit test may be broken with half file
      • advance command
        • revert
          • not like subversion
        • cherry pick
        • only if you know what it is in your stagign area
  • 4. Branching
    • HEAD
      • equals to most recent commit
      • is going to be the parent of the next commit
      • it is where the branch live
      • master is just another branch
      • a branch is at least 2 commit with the same parent
    • branch is fast because it is local
    • Play
      • create a branch
        • git branch feature
        • this do not switch to the branch
      • move to branch
        • git checkout feature

          check where you are working

          • git branch
          • git status

          vi caesar.txt

          git add caesar.txt

          git commit -m "add a title"

          git lg

      • merge feature to master
        • git checkout master
        • git merge feature
        • and kill that branch
          • better not used it if its a feature
    • git reset
      • if we discover an error in commit message 259a4c9
      • hard
        • reset both master and any branch
          • like merge has never happen
          • blow up old commit and create new ons!
          • dangerous you can lose code
      • Play
        • git reset --hard 259a4c9
        • git commit --amend
          • commits are lost
            • you can not find it
            • still there as an object but has no refs!
            • you have to remember the hash
            • may be garbage collected after 60 days
            • git reflog
              • may be still in there
        • you can then redo a git merge feature
      • better use rebase
        • 95% of git users dont know how
        • quite advanced
    • git branch adopted 259a4c9
      • create a branch adopted of the amended commit
    • delete the branch
      • git branch -d feature
        • delete the label of the branch
        • but the commit stay of course
      • git branch -d adopted
        • will complains as not merged
        • force the delete of non merged
        • git branch -D adopted
  • 5. merge conflict
    • GIT search for chunk that are similar and can merged automatically
    • Play
      • git merge feature
      • git status
        • show merge conflict
    • if you know what is in reflog
      • git reset --hard HEAD@{1}
      • you can undo last command
      • not always 1 command lead to only one entry in reflog
      • use with precaution
    • external merge tool
      • p4merge
        • config
          • git config --global merge.tool p4merge
          • git config --global mergetool.prompt false
          • git config --global mergetool.keepBackup false
          • git config --global mergetool.keepTemporaries false
        • use
          • git mergetool
    • to solve merge conflict on binary file
      • automatic merge not possible
      • you can decide your or theirs is the right one
      • git checkout --theirs -- animated.gif
        • git add animated.gif
          • git commit -m "use their version of binary animated.gif"
  • 7. GitHub
    • git remote add origin https://xxxxx/yyyy.git
      • create a local config at .git/config
      • origin is a convention name
    • git push
      • push unique content to remote
      • git push -u origin master
        • -u to make master

          remember that it

          track remote origin

      • git branch -a
        • now display also remote branch in red
    • git help daemon
      • share

        to start a git server

        to server your local

        git repo as a remote

        for colleagues

    • git help bundle
      • no network?

        write objects and refs into files

        for sharing on cdrom or

        shared drive

        for highla secure environment

        without network: ex military

    • git fetch
      • get all objects, blobs and commit

        but do not change master

        • just get and save commits

          in local remote area (read only)

          git checkout feature5

          • feature5 being in remote origin
          • will create a local branch feature5
    • git pull
      • do a git fetch and merge into master
    • git push
      • need no parameter but use push.default if it exist
      • every local branch will be pushed as default if none have been specified
      • use
        • git config --global push.default simple
          • to only push the branch where you have
          • set it if you dont know te default
        • git help config
          • upstream
          • simple
          • ...
      • when pushing failed
        • failed to push some refs upstream

          because there is a new commit

          in master which is ahead of mine

          fast forwards will work

          only if i have new stuff

          • git pull (make a merge)

            git push

            better would have been to

            make a rebase also to clear

            the noise of merging to push

    • Fun
  • 9. Collaborating
    • Play
      • git config --global credential.helper cache

        • work only in linux/mac

        vi cedric.txt

        git add .

        git commit -m "add file"

        git push

        • if not succed do a git pull

        gitk --all

        • see a lot of noise because

          of merge done by pull before

          each push

        force to rebase on pull is a

        good idea to remove noise

        • git config --local branch.master.rebase true
        • or better
          • git config --global branch.autosetuprebase always

    • tags
      • 3 differents

        • reference
          • git tag XXXXX hash
            • it is a reference
            • always point to commit
        • annotated
          • -a --annotate Make an unsigned, annotated tag object
          • git tag -a ANNOTATED_TAG
          • is an indirection to a tag
        • ...

        tags are not pushed

        by default to origin

        • git push
          • do nothing
        • git push origin ANNOTATED_TAG
          • push a specific tag
        • git push --tags
          • push all tags


        • a tag
          • git tag -d tagname
        • a branch
          • git push --delete origin branchname
          • git push origin :branchname
  • revealJS
  • filesystem
    • Hooks
      • entry point to hook
    • refs
    • objects
    • HEAD
      • commit youre on
  • 2. Log history
    • # git log
    • hash
      • 40 character hash
    • git log --format= email
    • git log --format=raw
      • useful for training
      • relationship tree -> parent -> author -> committer
        • it is a graph
          • important to understand
        • git log --graph
        • git log --graph --decorate --format=oneline
          • still a lot of hash
        • git log --graph --decorate --format=oneline --abbrev-commit
    • git log --patch
      • Show all history with patches
    • aliases
      • git lol
        • git config --global "log --graph --decorate --oneline --all"

          • like a puppet for developer
      • git lg
        • git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all"

  • 3. Diff
    • git diff
    • git diff --staged
      • what is my next commit will do?
    • git diff --word-diff
    • git diff HEAD
      • show changes between local and something in history
    • create scripts
      • ~/scripts/git-xxxxxx
      • ~/scripts/git-log
    • git log ec7674 -1 --patch
      • to look at a particular commit and its diff
    • git show ec7674
  • 4. move and rename
    • remove a file from VCS and keep local copy
      • git rm --cached -- <filename>
      • git commit -m "remove from vcs"
    • GIT integrity check
      • each commit contains at least one tree and one or more blobs
      • content is king
      • blobs
        • store file content
        • no permissions
        • no metadata
        • each blob is stored under first 2 character of hash directory in /objects
        • every change of a file create a NEW blob
          • diff is calculating the diff on demand

            not storing them like svn

      • tree
        • contains file name
        • references to one or many blobs
        • one to n tree in a commit
      • git pack
        • all commits can get packed to find similar blob
        • 5 to 10 times less space than SVN
      • git GC
        • find all commits, trees and blobs

          that can not be accessed and remove them

    • git add -u .
      • update only tracked file not moved/renamed  file
      • use instead
        • git add -A .
    • git checkout -- file3.txt
      • revert file content
    • similarity content analyser
      • if more then 50% then it count the the file as renamed otherwise it is new
      • git log -2 --stat
        • may show delete + add for a move operations
      • git log -2 --stat -M
        • display also similarity index
        • may show move correctly
        • git log -2 --stat -M90
          • with 90% similarity threashold
        • git log -2 --stat -M -- file3.txt
          • limit to file
        • git log -2 --stat -M --follow -- file3.txt
          • changes + move + create
  • 6. Rebase
    • interactive rebase
    • rewrite the history
      • changing authors or any other properties
    • preparation for merging
      • Rebase Rebase Fastforward
        • ex: to make my code changes in branch

          appear like a continuation of master

          • d19' = d19
          • e69' = e69
          • but still different commits!

          do it in branch

          you want to move

          • git rebase master
            • change shape of the graph

              keep timestamp and author

              pull of all commits of a branch &

              replay all commit in master

              • may create small conflicts

          make the history straightforward

          • especially if you have a lot of branches
            • otherwise look like a train station
          • but you hide informations
            • from which branch it was merged
      • non fastforward
      • history
        • is a graph not a list like in "git log"
        • it is not temporal but topological
    • interactive rebase
      • to group commits into one
        • "commits are stories not just checkpoints"
      • git rebase -i [start, end]
        • start = HEAD as default
        • end = hash
        • git rebase -i HEAD^
          • parent of head
          • you can combine HEAD^^^^^^
        • git rebase -i HEAD~10
          • last 10 commit
        • git rev-parse HEAD^
          • give hash
        • git help gitrevisions
          • adavnce list of expressions
        • create a file so you can decide what to do
          • has command
          • pick, reword, edit,squash, fixup and exec
          • you can not squash the oldest commit
  • 8. Forking
    • Play
      • git clone xxxx
      • vi xxxxx.txt
      • git add .
      • git commit -m ""
      • git push
      • open a pull request
    • pull request
      • invitation to start a conversation
      • add metadata
        • screenshots
      • is an iterative process
        • threaded discussion
    • ideas
      • when opening  a feature branch
        • create a pull request immediately
        • improve communication and awareness and start discussion
        • even if there is no code yet done
    • merge conflict can not be solved in github
      • has to be done in command line

You might like also

Docker essential tools: Dive to navigate docker image content
If you want to explore the content of a docker image, Dive is THE tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker image. Note that we will be exploring the image not the container: viewing the container and the image are not the same thing. You can get most of the time a bash access to a running container with  docker run -it image_name sh Or following for images with an entrypoint docker …
15 Days ago
#ALPINE-HACK19 4 – 5 October, 2019
On October 4th and 5th, the AlpineHack19 will be held, a blockchain-themed hackathon. The opportunity to bring together software developers, hackers, information technology enthusiasts and SMEs to showcase their know-how. The aim for the participants is to develop a functioning open-source software or #hardware prototype – solutions that eliminate real problems, for real companies. #Blockchain Technology will be the center of all predefined challenges. 24 hours of #Innovation, personal development and lots of fun. I will be there as hackathon mentor …
124 Days ago
CryptoMountain Rocks in Sion 3-5 october 2019
CryptoMountain Rocks is a platform for Blockchainers from the Crypto Valley and beyond that offers a very inter-active conference with presentations, panels and talks battles. I will be there 3 days as a speaker and hackathon mentor. The event discusses latest Blockchain applications and talks about the impact of the new token economy on the way we do business. In parallel there will be the first CryptoMountain Rocks #ALPINE-HACK19 covering themes such as Agriculture, Energy and Supply Chain. …
124 Days ago
A git workflow that is easy and scale for product development
There are numerous GIT workflow floating around like Centralized Workflow, Gitflow, Forking flow and Feature Branch Workflow Over the last 10 years, I have followed this really simple workflow, similar to the forking flow. it allow Parallel Development, features branches can be merged to any release branches or ideally Master Collaboration Feature branches also make it easier for two or more developers to collaborate on the same feature We consider Master the stable version of the product, this branch should be deployed automatically using …
148 Days ago
Using free Cloudflare for CDN and DDoS protection
Cloudflare, Inc. is an American web infrastructure and website security company, providing content delivery network services, DDoS mitigation, Internet security, and distributed domain name server services.  It will cost you 0$ (DDOS, CDN) to 20$ or more and offer you the following advantages DDoS is short for Distributed Denial of Service. DDoSis a type of DOS attack where multiple compromised systems, which are often infected with a Trojan, are used to target a single system causing a Denial of Service …
148 Days ago
Add Docker container logs in Splunk
With Splunk You will be able to optimize container usage by monitoring CPU, memory, disk and network performance metrics from your containers. Pay only for what you need by managing resources and measuring the impact on service reliability and container resource requirements. Get a complete overview of Kubernetes and OpenShift Environments Correlate performance metrics, container logs and OpenShift/Kubernetes configuration and metadata for a better understanding of how your infrastructure is performing and how hosted applications are behaving. …
148 Days ago
Installing latest Splunk in 5 minutes using Docker
From 0 to Splunk in 5 minutes using Docker and Compose Splunk is an American multinational corporation headquartered in San Francisco, California, which produces software for searching, monitoring, and analyzing machine-generated big data, via a web-style interface. Docker is an open source software platform to create, deploy and manage virtualized application containers on a common operating system (OS), with an ecosystem of allied tools.  Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. Then, with …
148 Days ago
Explore 142 Initial Exchange Offering  (IEO) by category, year and country
IEO is currently the most popular fundraising trend in the crypto industry. As the name suggests, Initial Exchange Offering is conducted over the crypto trading platform and exchanges. So unlike ICOs wherein crypto projects directly approach investors, IEOs involve a third-party in the form of crypto exchanges. …
242 Days ago
Security Token Offering (STO) statistics
Security token offering (STO) is a type of fundraising that is performed with a company offering tokenized securities. The defining feature of security token offerings is in its definition. Stocks, bonds and managed property trusts are another examples of securities. …
243 Days ago
systematization of knowledge within major blockchain protocols or consensus
Alexis Gauba presented a systematization of knowledge within major blockchain protocols or consensus, addresses the common challenges …
321 Days ago