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. Basic Operations

Create a Repo

PreviousInstall GitNextMake a Commit

Last updated 1 year ago

In this section, we will create an empty local repo.

From now on, it's assumed that you know the basic Linux commands in the Bash shell. If you're using a Mac or Linux you can open the terminal. If you're on Windows, you can download which bundles up the Linux commands.

Examples will be simulating a Python project. Feel free to try your own content.

First, navigate to an empty folder. This is where you will put your code and work mostly. Here, I will be using a folder called git-prj under my D drive. Note that the prompt is λ and the command is whatever follows. For example, this is the input and output of pwd, which prints the working directory.

λ pwd
D:\Work\git-prj

If we do a list now, there won't be any files

λ ls -la
total 4
drwxr-xr-x 1 panflutes 197121 0 May  2 15:17 ./
drwxr-xr-x 1 panflutes 197121 0 May  2 15:17 ../

Initialise

Now use git init to tell Git to make this folder a repo, meaning Git will start tracking this folder.

λ git init
Initialized empty Git repository in D:/Work/git-prj/.git/

If we list now, you will find the .git folder. This is where Git stores all the tracking information. On Linux, files started with a dot is hidden so include -a to show all files.

λ ls -la
total 8
drwxr-xr-x 1 panflutes 197121 0 May  2 15:21 ./
drwxr-xr-x 1 panflutes 197121 0 May  2 15:17 ../
drwxr-xr-x 1 panflutes 197121 0 May  2 15:21 .git/

You don't need to interact with .git directly. The Git commands will do all the work.

Cmder