Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  1. Exercise

Exercise 1

Fibonacci sequence

1, 1, 2, 3, 5, 8, ..... It starts with 1, 1. The n-th item FnF_nFn​ is given using the following equation:

Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2}Fn​=Fn−1​+Fn−2​

  • Initiate an empty repo;

  • Show all branches;

  • Define a function named fib() in a new file make_fibo.py

    • It takes an argument n and returns the first n items of the Fibonacci sequence (without using recursion).

    • Make a commit;

    • Show all branches;

  • Make a new branch called feature;

    • Show all branches;

  • Switch to the feature branch;

    • Show all branches;

    • Observe any difference from the previous one;

  • Add a new file called make_fibo_recur.py;

    • Implement the fib() using recursion;

    • Make a commit;

  • Switch to the master branch;

  • Rename the feature branch to new-branch;

    • Show all branches;

  • Try delete the new-branch;

    • Merge the new-branch into master;

    • Try delete the new-branch;

  • Show all branches;

PreviousResetNextExercise 2

Last updated 1 year ago