Git Cheat Sheet · Getting started
Create a repository
git init
To create a Git repository, go to the project folder and run git init. Git creates a hidden .git subfolder that will hold the whole history. Your files are not tracked yet: you need to stage them, then make a first commit.
What it does
Turns a folder into a git repository: the history is stored in its .git subfolder.
A use case
You have a folder of scripts that was never versioned and you want to start tracking its changes.
On the command line
git init- Turns the current folder into a Git repository.
git init <folder>- Creates the folder if it does not exist, then initializes it.
git init -b main- Sets the name of the first branch (main rather than master).
git add -A && git commit -m "First commit"- Records the initial state of the project.
In Merathon
- Open the repository menu (logo at the top left).
- Choose "Initialize…" then select the folder.
Frequently asked questions
How do I undo a git init?
Delete the .git folder at the root of the project. Your files stay intact; only the Git history goes away.
Do I need to run git init after a git clone?
No. A cloned repository is already initialized and linked to its "origin" remote.
How do I make main the default branch for all repositories?
Run git config --global init.defaultBranch main once.