Exercise: create a local repository¶
In this exercise you will create a local repository, and use this repository to create multiple commits, switch between branches, and inspect the repository history.
-
Create a new, empty repository in a directory called
git-exercise
. -
Create a
README.md
file and write a brief description for this repository. Record the contents ofREADME.md
in a new commit, and write a commit message. -
Write a script that generates a small data set, and saves the data to a CSV file. For example, this script could sample values from a probability distribution with fixed shape parameters. Explain how to use this script in
README.md
. Record your changes in a new commit. -
Write a script that plots these data, and saves the figure in a suitable file format. Explain how to use this script in
README.md
. Record your changes in a new commit. -
Add a tag
milestone-1
to the commit you created in the previous step. -
Create a new branch called
feature/new-data
. Check out this branch and modify the data-generation script so that it produces new data and/or more data. Record your changes in one or more new commits. -
Create a new branch called
feature/summarise
from the tag you created in step #5. Check out this branch and modify the plotting script so that it also prints some summary statistics of the data. Record your changes in one or more new commits. -
In your
main
ormaster
branch, and add a license. Record your changes in a new commit. -
In your
main
ormaster
branch, merge the two feature branches created in steps #6 and #7, and add a new tagmilestone-2
.
Self evaluation¶
Now that you have started a repository, created commits in multiple branches, and merged these branches, here are some questions for you to consider:
-
Have you committed the generated data file and/or the plot figure?
-
If you haven't committed either or both of these files, have you instructed
git
to ignore them? -
Did you add a meaningful description to each milestone tag?
-
How many commits modified your data-generation script?
-
How many commits modified your plotting script?
-
What changes, if any, were made to
README.md
since it was first created?
Tip
To answer some of these questions, you may need to run git
commands.