Introduction to git, copying files in the terminal, tmux, GitHub Pages, and create a blog in Quarto

Daily Note - 13/05/2024
1. Introduciton to git
Git repository is a folder that contains all the files and folders of a project. It is a version control system that allows you to keep track of changes in your code. It is a distributed version control system, which means that you can work on your code locally and then push it to a remote repository.
When you save, you basically take a snapshot of your code at that point in time (versoin control). This snapshot is called a commit. You can then go back to that commit at any time. You can also create branches, which are like parallel universes where you can work on different features of your code without affecting the main branch.
To put your repository in your computer, you can use the command git clone <repository_url>. This will create a folder with the name of the repository in your computer. You can then navigate to that folder and start working on your code.
We are going to clone it with something called SSH, which is a secure way to connect to a remote repository. To do this, you need to generate a SSH key in your computer and then add it to your GitHub account.
Using the command git status you can see the status of your repository. This will show you the files that have been modified, added or deleted.
If you want to add all the files that have been modified, you can use the command git add .. If you want to add a specific file, you can use git add <file_name>.
After adding the files, you need to commit them. To do this, you can use the command git commit -m "message". The message is a short description of the changes you made in that commit.
After committing the changes, you need to push them to the remote repository. To do this, you can use the command git push origin main. This will push the changes to the main branch of the remote repository.
2. Copying multiple files at once in the terminal to a specific directory
You can use a list of files to copy multiple files at once to a specific directory.
Terminal
cp test.csv sample_submission.csv train.csv ~/git/PSS3E9This will copy the files test.csv, sample_submission.csv and train.csv to the directory ~/git/PSS3E9.
You can also use pattern with wildcards to copy multiple files at once. For example, to copy all the files that end with .csv to a specific directory, you can use the following command:
Terminal
cp *.csv ~/git/PSS3E9Also you can use a pattern with curly braces to copy multiple files at once.
Terminal
cp {test,sample_submission,train}.csv ~/git/PSS3E93. Change to your most recent directory in the terminal
You can use the command cd - to change to your most recent directory in the terminal. This is useful when you want to go back to the directory you were before.
pushd and popd are also useful commands to navigate between directories. pushd saves the current directory and changes to the directory you specify. popd goes back to the directory you saved with pushd.
4. Instead of using multiple tab terminals, use tmux
Tmux is a terminal multiplexer that allows you to split your terminal into multiple panes. This is useful when you want to work on multiple things at once. You can create a new pane with Ctrl+b % and navigate between panes with Ctrl+b arrow keys. To create a new pane down, you can use Ctrl+b ".
You can close the panes with exit or Ctrl+d. To close tmux, you can use Ctrl+b d.
To get more room in the pane you are working on, you can use Ctrl+b z to zoom in and out.
The good thing about tmux is that runs in the background, so you can close your terminal and open it again and your panes will still be there. You need to first detach from tmux with Ctrl+b d and then close your terminal. To attach to tmux again, you can use tmux attach.
5. Quick start for GitHub pages
GitHub pages is a free service that allows you to host a website directly from a GitHub repository. You can use it to create a personal website, a blog, a portfolio, or a project page.
Check the GitHub Pages documentation for more information on how to get started.
6 Create a Quarto blog
Quarto is a tool that allows you to create documents in markdown and publish them as a website. You can use it to create a blog, a journal, a report, or a book.
First create a github repository with the same name of your project.
Using Quarto extension in VSCode, you can start a new Quarto project from the command palette with Quarto: New Project. You can then select the type of project you want to create (e.g., blog, journal, report, book). This will create a new folder with the necessary files to start writing your document.
Write the same name project that your github repository.
Once all the files are in the folder, you need to change your project configuration.
_quarto.yml
project:
type: website
output-dir: docsGo to the terminal and run quarto render to render the website.
Then you need to push the changes to the repository.
Terminal
git add .
git commit -m "Initial commit"
git push Go to the settings of your repository and select the source of your GitHub pages as main and the folder as docs.
You can then access your website at https://<username>.github.io/<repository_name>.
Findings and resources
- Very good video about version control and jupyter notebooks here
- Joel Grus book about why he doesn’t like notebooks. His website is here. He has a book called Data Science from Scratch.
- Joel Grus talk about why he doesn’t like notebooks here
Quarto Resources:
- Set up navigation
- Website tools (Google Analytics!)
- Customize your listing (front blog page)